Results 1 to 9 of 9

Thread: Problem deploying a two library + executable application to windows

  1. #1
    Join Date
    Nov 2010
    Posts
    14
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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:

    Qt Code:
    1. TEMPLATE = lib
    2.  
    3. QT += sql
    4.  
    5. TARGET = lib1
    6.  
    7. LIBS += -lstdc++
    8.  
    9. unix {
    10. UI_DIR = ../.ui
    11. MOC_DIR = ../.moc
    12. OBJECTS_DIR = ../.obj
    13. }
    14.  
    15. win32 {
    16. UI_DIR = ../ui
    17. MOC_DIR = ../moc
    18. OBJECTS_DIR = ../obj
    19. }
    20.  
    21. TARGET = $$qtLibraryTarget($$TARGET)
    22. target.path = $$[QT_INSTALL_PLUGINS]/designer
    23. INSTALLS += target
    24.  
    25. DESTDIR = ../bin
    To copy to clipboard, switch view to plain text mode 

    The second library (the designer plugin, using the first lib).

    Qt Code:
    1. TEMPLATE = lib
    2.  
    3. TARGET = lib2
    4.  
    5. QT += sql network xml
    6.  
    7. CONFIG += designer \
    8. plugin
    9.  
    10. LIBS += -lstdc++ -L../bin -llib1
    11.  
    12. INCLUDEPATH += . ../model
    13.  
    14. unix {
    15. UI_DIR = ../.ui
    16. MOC_DIR = ../.moc
    17. OBJECTS_DIR = ../.obj
    18. }
    19.  
    20. win32 {
    21. UI_DIR = ../ui
    22. MOC_DIR = ../moc
    23. OBJECTS_DIR = ../obj
    24. }
    25.  
    26. TARGET = $$qtLibraryTarget($$TARGET)
    27. target.path = $$[QT_INSTALL_PLUGINS]/designer
    28. INSTALLS += target
    29.  
    30. DESTDIR = ../bin
    To copy to clipboard, switch view to plain text mode 


    And finally, the executable .pro:

    Qt Code:
    1. TEMPLATE = app
    2.  
    3. TARGET = Contabilidad
    4.  
    5. QT += sql network xml
    6.  
    7. CONFIG += debug \
    8. qt \
    9. thread
    10.  
    11. INCLUDEPATH += ./ ventanas/
    12.  
    13. LIBS += -L../bin -L../sqldrivers -lstdc++ -lQtSql -llib1 -llib2
    14.  
    15. unix{
    16. UI_DIR = ../.ui
    17. MOC_DIR = ../.moc
    18. OBJECTS_DIR = ../.obj
    19. RCC_DIR = ../.rcc
    20. }
    21.  
    22. win32{
    23. UI_DIR = ../ui
    24. MOC_DIR = ../moc
    25. OBJECTS_DIR = ../obj
    26. RCC_DIR = ../rcc
    27. }
    28.  
    29. DESTDIR = ../bin
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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.

  3. #3
    Join Date
    Nov 2010
    Posts
    14
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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).

    Qt Code:
    1. 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
    2.  
    3. ./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x132): undefined reference to `fechaedit::RW()'
    4.  
    5. ./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x140): undefined reference to `fechaedit::RW()'
    6.  
    7. ./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x14e): undefined reference to `fechaedit::RW()'
    8.  
    9. ./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x7e1): undefined reference to `fechaedit::fecha()'
    10.  
    11. ./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x81f): undefined reference to `fechaedit::fecha()'
    12.  
    13. ./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x85d): undefined reference to `fechaedit::fecha()'
    14.  
    15. ./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x89e): undefined reference to `fechaedit::fecha()'
    16.  
    17. ./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x9e9): undefined reference to `fechaedit::RO()'
    18.  
    19. ./..\obj\unidadesservicio.o:unidadesservicio.cpp:(.text+0x9f7): undefined reference to `fechaedit::RO()'
    20.  
    21. ................................................................................
    22.  
    23. goes on and on until almos 300 errors like this ones.
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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.

  5. #5
    Join Date
    Nov 2010
    Posts
    14
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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 :

    Qt Code:
    1. 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
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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?

  7. #7
    Join Date
    Nov 2010
    Posts
    14
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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...
    Last edited by joseprl89; 15th March 2011 at 21:16.

  8. #8
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default 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.

  9. #9
    Join Date
    Nov 2010
    Posts
    14
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

Similar Threads

  1. Font problem when deploying a Qt-based application to Ubuntu 10.10
    By dictoon in forum Installation and Deployment
    Replies: 8
    Last Post: 13th March 2011, 21:26
  2. Replies: 3
    Last Post: 21st February 2011, 01:20
  3. Deploying an application on windows
    By dmcr in forum Installation and Deployment
    Replies: 1
    Last Post: 23rd September 2009, 10:23
  4. problem with deploying static application in windows
    By remy06 in forum Installation and Deployment
    Replies: 3
    Last Post: 2nd June 2009, 07:46
  5. Replies: 7
    Last Post: 11th March 2006, 16:51

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.