Solved Looking for good explanation of creation process of Static Lib and it's Test App
-
First thing: are you sure your library is properly statically built on Windows ?
If not, then I would guess you are not properly exporting the symbols from that library hence the missing symbol.
-
@SGaist said in Looking for good explanation of creation process of Static Lib and it's Test App:
First thing: are you sure your library is properly statically built on Windows ?
How I should check this?
-
Are you properly setting the static flag in your library project ? Do you get a .dll when building on Windows ?
-
@SGaist said in Looking for good explanation of creation process of Static Lib and it's Test App:
Are you properly setting the static flag in your library project ? Do you get a .dll when building on Windows ?
Yes. Dll and Lib files are created after building lib.
-
Then your library is not build statically and you are not properly exporting symbols.
For that second part see here.
-
@SGaist thanks. I will recode my lib.
I there any way to debug dynamic/static lib?
-
Sure, use a debug build of your library.
-
@SGaist ones more Q:
But how the same project works in Linux? -
Because the symbol exportation does not work the same on Linux.
-
When you have a library under windows you need to explicitly export the symbols.
On linux it is not necessary because the symbols are managed in another way.Typically this is done using a preprocessor define that you add at any function / class that you wanna export like (just look it up on stackoverflow)
#ifdef WIN32 #define DECL_EXPORT __declspec(dllexport) #define DECL_IMPORT __declspec(dllimport) #else #define DECL_EXPORT #define DECL_IMPORT #endif
-
@gde23 said in Looking for good explanation of creation process of Static Lib and it's Test App:
When you have a library under windows you need to explicitly export the symbols.
On linux it is not necessary because the symbols are managed in another way.Typically this is done using a preprocessor define that you add at any function / class that you wanna export like (just look it up on stackoverflow)
#ifdef WIN32 #define DECL_EXPORT __declspec(dllexport) #define DECL_IMPORT __declspec(dllimport) #else #define DECL_EXPORT #define DECL_IMPORT #endif
That is incomplete, The macro to use depend whether you are building the library or using it. See the dedicated chapter in Qt's documentation for a clean way to handle that.
-
-
-
@gde23 said in Looking for good explanation of creation process of Static Lib and it's Test App:
@SGaist You are right. I forgot to mention that part.
@sitesv The dll will be created also if you do not export the symbols. But the exe will not know about the function/class inside the dll so it will not find them.
Did you include the defines as in the description SGaist posted?Yes. I checked it. Could you view my code by this link?
UPD: I inserted the line "extern int test();" to main.cpp. And voila!