Problem with extern and linkage
-
Hi, I'm using a library and I need to redirect function calls in that library. What I mean is that in the library, there are calls to a function and I want the calls to be calls of another function. The problem is that I can't include that file, where those new functions are to the library and I can't modify that library very much. So, I'm using extern and define in the files of the library to solve the problem and I'm able to make the library without compilation/linking errors. The problem is how to link/compile/include the library with my application? Now I keep getting LNK2001 errors telling me that the library doesn't find the definitions of those functions. I'm using makefile and in there I have linked the object file that contains the new functions to be used and also the library. That is apparently not enough. I even tried putting the object file before the library when linking. -Janetta
-
Hi, I'm using a library and I need to redirect function calls in that library. What I mean is that in the library, there are calls to a function and I want the calls to be calls of another function. The problem is that I can't include that file, where those new functions are to the library and I can't modify that library very much. So, I'm using extern and define in the files of the library to solve the problem and I'm able to make the library without compilation/linking errors. The problem is how to link/compile/include the library with my application? Now I keep getting LNK2001 errors telling me that the library doesn't find the definitions of those functions. I'm using makefile and in there I have linked the object file that contains the new functions to be used and also the library. That is apparently not enough. I even tried putting the object file before the library when linking. -Janetta
Maybe you're misxing C and C++ styles of linking. Make sure the portion of library using the external function and the object code providing it are the same language. You can also use
extern "C"
in both parts if the languages are different. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
Maybe you're misxing C and C++ styles of linking. Make sure the portion of library using the external function and the object code providing it are the same language. You can also use
extern "C"
in both parts if the languages are different. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo