Problem deploying a two library + executable application to windows
I've been coding an application for a couple months on linux, using Qt 4.7.0, and lately i decided to deploy it to windows.
In linux, i have no problem when compiling the whole application (containing a library, a designer plugin, and a executable), but when porting to windows I had some problems with the library (all solved thanks to this forum).
Now that I have both libraries working, the executable project won't compile, prompting a lot of "undefined reference to" errors when linking the libraries.
I have checked that the Qt Creator can compile using the Qt demos, so i guess it's an error in the project files, so i include the configurations i am using:
First library:
Code:
TEMPLATE = lib
QT += sql
TARGET = lib1
LIBS += -lstdc++
unix {
UI_DIR = ../.ui
MOC_DIR = ../.moc
OBJECTS_DIR = ../.obj
}
win32 {
UI_DIR = ../ui
MOC_DIR = ../moc
OBJECTS_DIR = ../obj
}
TARGET = $$qtLibraryTarget($$TARGET)
target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target
DESTDIR = ../bin
The second library (the designer plugin, using the first lib).
Code:
TEMPLATE = lib
TARGET = lib2
QT += sql network xml
CONFIG += designer \
plugin
LIBS += -lstdc++ -L../bin -llib1
INCLUDEPATH += . ../model
unix {
UI_DIR = ../.ui
MOC_DIR = ../.moc
OBJECTS_DIR = ../.obj
}
win32 {
UI_DIR = ../ui
MOC_DIR = ../moc
OBJECTS_DIR = ../obj
}
TARGET = $$qtLibraryTarget($$TARGET)
target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target
DESTDIR = ../bin
And finally, the executable .pro:
Code:
TEMPLATE = app
TARGET = Contabilidad
QT += sql network xml
CONFIG += debug \
qt \
thread
INCLUDEPATH += ./ ventanas/
LIBS += -L../bin -L../sqldrivers -lstdc++ -lQtSql -llib1 -llib2
unix{
UI_DIR = ../.ui
MOC_DIR = ../.moc
OBJECTS_DIR = ../.obj
RCC_DIR = ../.rcc
}
win32{
UI_DIR = ../ui
MOC_DIR = ../moc
OBJECTS_DIR = ../obj
RCC_DIR = ../rcc
}
DESTDIR = ../bin
Any help would be really appreciated, because i've been trying to deploy to windows for a couple of days and I just can't see the problem (guess its a silly one).
Best Regards
Josep
Re: Problem deploying a two library + executable application to windows
It would probably help if you could show the output from the linking stage. If it is very long, just show the first couple of lines and attach a text file with the entire log. There are a few differences in how windows and linux store intermediate/object files. However, you are using dedicated folders for those. I'm not sure if the location of the target (lib/dll for library, exe for application) is the same in both cases.
Re: Problem deploying a two library + executable application to windows
Here you have the step that gets the error while compiling and some of the errors (almost 300 of the same error appear).
Code:
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o ..\bin\Contabilidad.exe object_script.Contabilidad.Release -L"c:\Qt\2010.05\qt\lib" -lmingw32 -lqtmain -L../bin -L../sqldrivers -lstdc++ -lQtSql4 -lpronetModel -lcont -lQtSql4 -lQtGui4 -lQtCore4
./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x132): undefined reference to `fechaedit::RW()'
./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x140): undefined reference to `fechaedit::RW()'
./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x14e): undefined reference to `fechaedit::RW()'
./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x7e1): undefined reference to `fechaedit::fecha()'
./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x81f): undefined reference to `fechaedit::fecha()'
./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x85d): undefined reference to `fechaedit::fecha()'
./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x89e): undefined reference to `fechaedit::fecha()'
./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x9e9): undefined reference to `fechaedit::RO()'
./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x9f7): undefined reference to `fechaedit::RO()'
................................................................................
goes on and on until almos 300 errors like this ones.
Re: Problem deploying a two library + executable application to windows
I don't see lib1 or lib2 being linked in - perhaps the linker has problem locating them?
It may be helpful to compare the output from the linker between linux and windows.
Re: Problem deploying a two library + executable application to windows
The linux output works correctly, without prompting errors, I just don't get why it says all those undefined error, because the compiler does recognize the libraries (if i remove the -lpronetModel and -lcont from the .pro file, it prompts an error telling me that the compiler hasn't found the required libs).
By the way, the real name of lib1 and lib2 are cont and pronetModel (libXXX.so in linux and XXX.dll in windows), so the linker does uses them :
Code:
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -mthreads -Wl -Wl,-subsystem,windows -o ..\bin\Contabilidad.exe object_script.Contabilidad.Release -L"c:\Qt\2010.05\qt\lib" -lmingw32 -lqtmain -L../bin -L../sqldrivers -lstdc++ -lQtSql4 -lpronetModel -lcont -lQtSql4 -lQtGui4 -lQtCore4
Re: Problem deploying a two library + executable application to windows
so which library contains fechaedit?
when you moved the project over to windows, did you do a proper clean project? Remove all make files, <project>.pro.user, object_script*.* files?
Is there a way to build a small app just using one of the libs?
Re: Problem deploying a two library + executable application to windows
fechaedit is located at the libcont.so library, it is a widget plugin library, so I decided to see if the designer can load it.
It can't, the error it displays is:
Cannot load library ...../cont.dll: The specified module can not be found.
Added after 5 minutes:
I tried to create a new simple application, and if i tried to use LIBS += -lcont it crashed with the same results as the original project, but without it, it just runned fine.
It's quite strange because when compiling the lib "cont" not a single error appears...
Re: Problem deploying a two library + executable application to windows
Is it possible that you need to also provide a dll besides the lib and place it in a subfolder below the location of the executable?
Perhaps take another look at a plugin example to see if there is anything platform specific for windows.
It looks to be more than a linker problem.
sorry I can't be of more help - I have never created a plugin library. Hopefully some more experienced users can chime in.
Re: Problem deploying a two library + executable application to windows
I checked the demos when facing this error, and It doesn't seem to do anything different than me, just placing the lib in the designer plugins folder.
Don't worry, any help is appreciated.