[solved] building shared DLL creates static .a
-
Hi,
What do you get if you do a clean build ?
IIRC, when both static and shared lib are present in the same folder, there might be the possibility that the static is used by default for the linking part
-
Clean builds bring out the same result every time: lua5.a (176KB) and lua5.dll (175KB).
Yes, the static lib (lua5.a) should help linking the DLL to the application. But as I said previously, when using this lib, it just links statically and the DLL file is not needed in order to run the application. Here, see this:
http://www.mediafire.com/download/uw52klc7g987owm/interpreter.zip
The lua interpreter (lua.exe) compiled via cmd and makefile is only 19KB and requires the DLL (rename the DLL file to something different and try to run, you'll get an error). The same should happen when I compile from QtCreator but instead I get a 170KB exe file, and no DLL requirement. This means that the output file lua5.a is just the static lib version and it's not related to the DLL in any way.In the qmake project file I tried to add this to the DLL build:
@QMAKE_CXXFLAGS_SHLIB = -Wl,--out-implib,lib$$TARGET@
but seems it has no effect.EDIT
BTW, here are the compiled DLL and .a file:
http://www.mediafire.com/download/cyxypupxs1a49m9/dll.zip
Try linking against them yourself if you can and let me know if I am doing something wrong when linking...(note: links are to my mediafire account, you can trust they're not malicious)
-
Sorry, I misunderstood you. One thing I would add to your pro file is:
@
CONFIG -= staticlib static
@when you build the shared version, to ensure you don't have them lying around
-
Just did that, nothing has changed...
I can tell the "lib" and "dll" builds produce a different .a file. The dll build .a file is 176KB, while the one from the lib build is 239KB.
I really can't understand why they behave the same if they're different. Do you know any other flags that I could set/unset related to this? Maybe some flags that let me specify which output file name to set for the .a file?
-
TARGET is the correct variable to play with the library name.
Did you took a look of you application with e.g. Dependency Walker to see what it relies on to work ?
-
I just did that right now.
Compiling the interpreter with the .a file from the dll build creates no DLL dependency on lua5.dll. In fact all I get is it depends on KERNEL32.DLL and MSVCRT.DLL.
Runnind Dependency Walker on the interpreter built manually via makefile reports an additional dependency on LUA52.DLL.EDIT
Something that got in my mind is to have the Makefile included in the Lua sources, ported to the project file... I'm searching for guides but can't find much right now... -
what about adding @CONFIG += plugin@
-
Nope... I get exact same result as with "shared" or "dll", compiled files are the exact same.
I am trying now to get it compiled using the "vclib" template. It's not working right now, it says:
@00:56:57: Running steps for project lua523...
00:56:57: Starting: "C:\Qt\Versions\Qt-5.2.0-x86-ANGLE\bin\qmake.exe" D:\Progetti\Qt\lua523\lua523.pro -r -spec win32-g++ "CONFIG+=release" CONFIG+=shared
Project MESSAGE: Building shared library
Project MESSAGE: Building shared library
Project MESSAGE: Building shared library
WARNING: Unable to generate output for: D:/Progetti/Qt/Builds/lua523/[32-bit] Qt 5.2.0 ANGLE/Makefile.Release [TEMPLATE vclib]
WARNING: Unable to generate output for: D:/Progetti/Qt/Builds/lua523/[32-bit] Qt 5.2.0 ANGLE/Makefile.Debug [TEMPLATE vclib]
00:56:57: The process "C:\Qt\Versions\Qt-5.2.0-x86-ANGLE\bin\qmake.exe" exited normally.
00:56:57: Starting: "C:\Qt\Compilers\mingw32-4.8.2-win32-SJLJ\bin\mingw32-make.exe"
C:/Qt/Compilers/mingw32-4.8.2-win32-SJLJ/bin/mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'D:/Progetti/Qt/Builds/lua523/[32-bit] Qt 5.2.0 ANGLE'
mingw32-make[1]: Makefile.Release: No such file or directory
mingw32-make[1]: *** No rule to make target 'Makefile.Release'. Stop.
mingw32-make[1]: Leaving directory 'D:/Progetti/Qt/Builds/lua523/[32-bit] Qt 5.2.0 ANGLE'
Makefile:34: recipe for target 'release' failed
mingw32-make: *** [release] Error 2
00:56:59: The process "C:\Qt\Compilers\mingw32-4.8.2-win32-SJLJ\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project lua523 (kit: [32-bit] Qt 5.2.0 ANGLE)
When executing step 'Make'
00:56:59: Elapsed time: 00:02.@So yeah, I've got to check the docs about this template and see if can get it to work.
-
hm... it sound strange... what abut the settings that you have for shadow building? are you using Qt Creator?
-
Yes, I am using QtCreator 3 with precompiled qt 5.2.0 binaries (I have both ANGLE and OpenGL versions, both 32 and 64 bit) from the "qtx64 project":http://sourceforge.net/projects/qtx64/ and mingw32/mingw64 compiler.
My projects are located in D:\Progetti\Qt while my shadow builds are located in a subdirectory, D:\Progetti\Qt\Builds. I did not have any issues before due to this configuration though... -
I have finally found the problem to this, and I thought I would update this thread.
As often happens to many, I skipped the "check documentation" step. It was clearly advertized by Lua documentation that people should check the file "luaconf.h" to properly set up Lua.
Long story short, I should have done a #define LUA_BUILD_AS_DLL, so Lua source code would understand that the code is to be compiled into a shared library, not a static one. When adding that define (it can also be done in qmake via DEFINES += LUA_BUILD_AS_DLL ) it all works flawlessly.Even more, I have spent some time on a Qt Creator project that can help people compiling Lua in Qt Creator within clicks. You may want to check it here:
http://qt-project.org/forums/viewthread/50621/By the way, I just noticed I forgot to thank the people who answered this thread... I'm really sorry guys. If it still means anything to you, thank you very much!
-
I have finally found the problem to this, and I thought I would update this thread.
As often happens to many, I skipped the "check documentation" step. It was clearly advertized by Lua documentation that people should check the file "luaconf.h" to properly set up Lua.
Long story short, I should have done a #define LUA_BUILD_AS_DLL, so Lua source code would understand that the code is to be compiled into a shared library, not a static one. When adding that define (it can also be done in qmake via DEFINES += LUA_BUILD_AS_DLL ) it all works flawlessly.Even more, I have spent some time on a Qt Creator project that can help people compiling Lua in Qt Creator within clicks. You may want to check it here:
http://qt-project.org/forums/viewthread/50621/By the way, I just noticed I forgot to thank the people who answered this thread... I'm really sorry guys. If it still means anything to you, thank you very much!