Help me with Shared Library before going crazy

I have a GUI project and a Shared Library with functions that are used by the GUI project. I have up to 11 functions (of which only 10 are shared with the GUI project. They are defined into the header of the DLL like this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
struct MYSTRUCT{
    int i;
    char* value;
};

char* func1(char*, char*);
char* func2(char*, char*);

char* func3(char*);
void func4(char*, char*);
char* func5(int, char*);
vector<MYSTRUCT> func6();
char* func7(string);
bool func8(char*, char*);
string func9();
void func10(char*, bool);


Everything was so cool until I tried to add another function. I compile and build the DLL, then, when I try to use the function inside my GUI project, after compiling I get this weird and demonic error

obj\Release\main.o:main.cpp|| undefined reference to `func11'|


The Shared Library project is compiled without problem and the DLL is created. If I don't use it in my GUI project, the other 10 functions work wonderful (which means everything is linked correctly). It doesn't matter what function is it (a simple bool function that returns a false, a void one, the same result) It is like the DLL can only export a limited number of functions. What the heck is happening. I thing I am going crazy with these kind of situations, when the most unexpected happens when your life could not be better.
Thanks!
Last edited on
1. Use Dependency Walker to see the exported functions.
2. Make sure you export the functions using extern "C" if you are using a C++ compiler.
3. Make sure func11() is declared in the header file in use by the GUI project.
Dependency Walker finds the function func11(), so it is exported
Yes, I use extern "C". I am using GNU compiler
The function is declared in the header.
This is going strange
Last edited on
Then just try and use explicit linking in your executable instead using LoadLibrary() and GetProcAddress() instead of implicit linking using your DLL import library. You don't really need DLL header file in this case (of course, you still need to know func11 function prototype).


However, you are using now implicit linking, so it is NOT required to export any function for things to work. DependencyWalker will not help you.
Last edited on
It seems like the .lib file doesn't update. I removed several functions from the DLL, keeping their declarations in the header file. When I compile the main GUI project I don't get any error but when I start the executable a message saying that the addressed functions does not exist in the DLL appears. So, when I remove the function from the DLL, when rebuilding, the .lib file keeps the references to them (at least is what I suppose)
I would prefer to not use explicit linking. It will take me some time to replace all the places where functions from DLL are used. LoadLibrary? GetProcAddress(). I don't use any of these to call functions from my DLL. The .lib is included into the project Linker settings, the .h file, and the dll is added to the same folder as the .exe of my GUI project. Maybe I am not linking the library correctly.
Last edited on
It is clear to me that your IDE settings are messed up (try renaming your *.lib before rebuilding to see if it is recreated). I think you are linking with a wrong import library, there is no way that the import library to not be updated if the DLL is builded correctly.
Stupid me. Indeed, I fucked up the build settings of the Library project. Thanks everybody!
Topic archived. No new replies allowed.