Page 1 of 2 12 LastLast
Results 1 to 20 of 28

Thread: project with a dll and a testprog (doesn't compile)

  1. #1
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default project with a dll and a testprog (doesn't compile)

    Hi, i have the following structure in my project:
    tester/tester.pro
    tester/tester.cpp
    calina/widget.h
    calina/widget.cpp
    calina/calina.pro
    main.pro

    main.pro
    Qt Code:
    1. SUBDIRS += calina \
    2. tester
    3. TEMPLATE = subdirs
    4. CONFIG += warn_on \
    5. qt \
    6. thread
    To copy to clipboard, switch view to plain text mode 

    calina.pro
    Qt Code:
    1. TEMPLATE = lib
    2.  
    3. CONFIG += dll \
    4. debug \
    5. opengl \
    6. x11
    7. CONFIG -= release \
    8. stl \
    9. thread
    10. QT += xml \
    11. opengl
    12. TARGET = ../bin/calina
    13.  
    14. HEADERS += widget.h
    15.  
    16. SOURCES += widget.cpp
    To copy to clipboard, switch view to plain text mode 

    tester.pro
    Qt Code:
    1. TEMPLATE = app
    2.  
    3. CONFIG -= release \
    4. stl \
    5. thread
    6. CONFIG += debug \
    7. opengl
    8. QT += xml \
    9. opengl
    10. INCLUDEPATH += ../calina
    11.  
    12. LIBS += -L../calina \
    13. -l../bin/calina
    14. TARGETDEPS += ../calina/lib../bin/calina.so
    15.  
    16. SOURCES += tester.cpp
    To copy to clipboard, switch view to plain text mode 

    tester.cpp
    Qt Code:
    1. #include "widget.h"
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5.  
    6. calina::Widget widget;
    7. widget.doSomething();
    8.  
    9. return 0;
    10. }
    To copy to clipboard, switch view to plain text mode 

    but if i try to compile it, i get the followin error
    ## no error, the lib is compiled and then moved to /bin/libcalina.so.1.0.0
    make[1]: Leaving directory `/home/damdam/Documents/projekte/dipl_arb/source/calina'
    cd tester && /usr/bin/qmake tester.pro -unix -o Makefile
    cd tester && make -f Makefile
    make[1]: Entering directory `/home/damdam/Documents/projekte/dipl_arb/source/tester'
    g++ -c -pipe -g -Wall -W -D_REENTRANT -DQT_XML_LIB -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/default -I. -I/usr/include/QtCore -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include/QtGui -I/usr/include/QtOpenGL -I/usr/include/QtOpenGL -I/usr/include/QtXml -I/usr/include/QtXml -I/usr/include -I../calina -I/usr/X11R6/include -I. -I. -o tester.o tester.cpp
    tester.cpp:33: warning: unused parameter ‘argc’
    tester.cpp:33: warning: unused parameter ‘argv’
    make[1]: *** Keine Regel vorhanden, um das Target »../calina/lib../bin/calina.so«,
    benötigt von »tester«, zu erstellen. Schluss.
    //make[1]: *** No rule to create target >>../calina/lib.......s<<
    // needed by >>teser<<
    make[1]: Leaving directory `/home/damdam/Documents/projekte/dipl_arb/source/tester'
    make: *** [sub-tester-make_default] Fehler 2
    // .. error 2
    Can you pleas help me?
    Last edited by jacek; 2nd July 2007 at 11:51. Reason: changed [code] to [quote]

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    Try this :

    calina.pro :
    Qt Code:
    1. TEMPLATE = lib
    2. CONFIG += dll debug
    3. CONFIG -= thread stl release
    4. DESTDIR = ../bin
    5. QT += xml opengl
    6. TARGET = calina
    7. HEADERS += widget.h
    8. SOURCES += widget.cpp
    To copy to clipboard, switch view to plain text mode 

    tester.pro :
    Qt Code:
    1. TEMPLATE = app
    2. CONFIG += debug
    3. CONFIG -= thread stl release
    4. QT += xml opengl
    5. INCLUDEPATH += ../calina
    6. LIBS += -L../bin -lcalina
    7. SOURCES += tester.cpp
    To copy to clipboard, switch view to plain text mode 
    Current Qt projects : QCodeEdit, RotiDeCode

  3. #3
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    Thank you, it compiles fine now. But when i try to execute it, i get the following error:

    ./tester/tester: error while loading shared libraries: libcalina.so.1: cannot open shared object file: No such file or directory

    The lib is in
    ./bin/libcalina.so
    ./bin/libcalina.so.1
    ./bin/libcalina.so.1.0
    ./bin/libcalina.so.1.0.0

    The exe file
    ./tester/tester

    The same, if both the .so files and the tester (bin/exe) are in the same dir..

    lld on the tester (exe) shows
    Qt Code:
    1. linux-gate.so.1 => (0xffffe000)
    2. libcalina.so.1 => not found
    3. libQtXml.so.4 => /usr/lib/libQtXml.so.4 (0xb7f12000)
    4. ...
    To copy to clipboard, switch view to plain text mode 

    I know whats wrong, but i don't know, how to solve it..

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    Quote Originally Posted by aMan View Post
    ./tester/tester: error while loading shared libraries: libcalina.so.1: cannot open shared object file: No such file or directory
    There are two solutions. Either you have to edit your /etc/ld.so.conf (or /etc/ls.so.conf.d/something) and run ldconfig as root or make LD_LIBRARY_PATH environment variable point to a directory where the library is.

  5. The following user says thank you to jacek for this useful post:

    darkadept (30th August 2007)

  6. #5
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    thank you, it works..

  7. #6
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    Hi,
    I have still the same pro files, as posted above by fullmetalcoder, but now i'm on windows with vs2005.

    The lib is compiled fine and a dll is created. But when it comes to compile the tester program, i get an error like this (translated from german):
    link /LIBPATH:"c:\qt\lib" /NOLOGO /DEBUG /SUBSYSTEM:WINDOWS /incremental:no /OUT:"..\bin\tester.exe" @C:\DOKUME~1\damdam\LOKALE~1\Temp\nm817.tmp
    LINK : fatal error LNK1181: Input file "calina.lib" couldn't be opened.
    .
    NMAKE : fatal error U1077: ""C:\Programme\Microsoft Visual Studio 8\VC\BIN\link.EXE"": Return-Code "0x49d"
    Stop.
    NMAKE : fatal error U1077: ""C:\Programme\Microsoft Visual Studio 8\VC\BIN\nmake.exe"": Return-Code "0x2"
    Stop.
    NMAKE : fatal error U1077: "cd": Return-Code "0x2"
    Stop.
    I do compiling with qmake nmake and nothing else. Please help me..

  8. #7
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    Open the project properties and under Linker look at:
    • General, and see if you have the directory of the lib file listed in "Additional library directories". If not, add it there.
    • Input, at "Additional Dependencies" and see if you have "calina.lib" listed there. Also, if it isn't there, add it yourself.

    EDIT: Well yes, as I can see from your post, you don't meet the conditions for the first point in the solution I have suggested.
    So do this, and see if you get any other errors. You shouldn't.

    Regards

  9. #8
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    I'm compiling on the command line, so I don't have a project file (only makefiles) and cannot open vs. And I don't have an lib file too (should have mentioned that), because I want dynamic linking..

    There should be an option in the pro file for fixing that, but i don't know it (it has to be in the pro file, because it must be platform independant..)

  10. #9
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    But that lib is just the import library used by the linker to link your application to the dll.
    So, even if you link dynamically, you will still need a ".lib" to map the functions in your program's import address table to the dll library.

    Try with DEPENDPATH qmake variable and set it to the path of the additional dependencies directories( your library).


    Regards

  11. #10
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    So how can i get the lib file?

    I've tried compiling the lib statically and a calina.lib was created, but the result of compiling the tester was static too.

    I've looked into the qt/lib directory. For instance QtGui has 9 files:
    QtGui4.dll
    QtGui4.exp
    QtGui4.lib
    QtGui.prl

    QtGuid4.dll
    QtGuid4.exp
    QtGuid4.lib
    QtGuid4.pdb
    QtGuid.prl

    I assume the d in the second list stands for debug, because there is also a pdb file (program debug file from vs). But there are still 4 files for one lib, in my project there is only one (calina.dll) created.

  12. #11
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    It will be generated automatically...
    It is by default placed in Debug or Release, depending on which target you compile/.

    Regards

  13. #12
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    They aren't. In the debug/releas folders are only the moc_blabla.cpp, blabla.obj and calina.intermediate.manifest files.

  14. #13
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    check out your destdir... the .lib (and maybe .exp whatsoever...) should be in the same dir as the .dll unless they fail to be created which you would see when compiling the lib.
    Current Qt projects : QCodeEdit, RotiDeCode

  15. #14
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    I've looked into all directories, I've even tried to remove the target and destdir variables, but nmake always creates only the dll..

    Maybe I could post the project as an zip file and you look into it (if that isn't too much work)?

  16. #15
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    can't you send us the very last lines of compilation output? Those which would inform us of the linking process... If I remember well, under Windows, a missing symbol (e.g. a function defined but not implemented) can prevent the import library from being created...
    Current Qt projects : QCodeEdit, RotiDeCode

  17. #16
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    Qt Code:
    1. compiling, compiling blabla...
    2. cl -c -nologo -Zm200 -GS -O2 -MD -DNDEBUG -GR -EHsc -W3 -DUNICODE -DQT_L
    3. ARGEFILE_SUPPORT -DWIN32 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
    4. -DQT_THREAD_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_XML_LIB -DQT_OPENGL_LIB -DQT_GUI
    5. _LIB -DQT_CORE_LIB -I"c:\qt\include\QtCore" -I"c:\qt\include\QtCore" -I"c:\qt\in
    6. clude\QtGui" -I"c:\qt\include\QtGui" -I"c:\qt\include\QtOpenGL" -I"c:\qt\include
    7. \QtOpenGL" -I"c:\qt\include\QtXml" -I"c:\qt\include\QtXml" -I"c:\qt\include" -I"
    8. c:\qt\include\ActiveQt" -I"release" -I"." -I"c:\qt\mkspecs\win32-msvc2005" -Fore
    9. lease\ @C:\DOKUME~1\damdam\LOKALE~1\Temp\nm2.tmp
    10. moc_widget.cpp
    11. moc_layout.cpp
    12. moc_glwidget.cpp
    13. moc_graphicsobject.cpp
    14. Code is getting generated... //orig german: Code wird generiert..
    15. link /LIBPATH:"c:\qt\lib" /NOLOGO /DLL /MANIFESTFILE:"release\calina.int
    16. ermediate.manifest" /incremental:no /OUT:"..\bin\calina.dll" @C:\DOKUME~1\damdam
    17. \LOKALE~1\Temp\nm3.tmp
    18. mt.exe -nologo -manifest "release\calina.intermediate.manifest" -outputr
    19. esource:..\bin\calina.dll;2
    To copy to clipboard, switch view to plain text mode 

    There are some warnings because of converting double to float, but i don't think that should make any difference..

  18. #17
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    C:\environments\tests\libtest>nmake

    Microsoft (R) Program Maintenance Utility Version 7.10.3077
    Copyright (C) Microsoft Corporation. All rights reserved.

    nmake -f Makefile.Debug

    Microsoft (R) Program Maintenance Utility Version 7.10.3077
    Copyright (C) Microsoft Corporation. All rights reserved.

    cl -c -nologo -Zm300 -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -D
    WIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUP
    PORT -I"..\..\..\Qt\4.3.0rc1\include\QtCore" -I"..\..\..\Qt\4.3.0rc1\include\QtC
    ore" -I"..\..\..\Qt\4.3.0rc1\include\QtGui" -I"..\..\..\Qt\4.3.0rc1\include\QtGu
    i" -I"..\..\..\Qt\4.3.0rc1\include" -I"." -I"..\..\..\Qt\4.3.0rc1\include\Active
    Qt" -I"debug" -I"." -I"..\..\..\Qt\4.3.0rc1\mkspecs\default" -Fodebug\ @D:\DOCUM
    E~1\Marcel\LOCALS~1\Temp\nm76E.tmp
    libtest.cpp
    libtest.cpp(4) : warning C4273: 'libtest::libtest' : inconsistent dll linkage
    libtest.cpp(9) : warning C4273: 'libtest::~libtest' : inconsistent dll linkage
    link /LIBPATH:"c:\Qt\4.3.0rc1\lib" /NOLOGO /DEBUG /DLL /OUT:debug\libtes
    t.dll @D:\DOCUME~1\Marcel\LOCALS~1\Temp\nm76F.tmp
    Creating library debug\libtest.lib and object debug\libtest.exp

    C:\environments\tests\libtest>
    ################################################## ####################
    # Automatically generated by qmake (2.01a) Tue Jul 24 22:10:16 2007
    ################################################## ####################

    TEMPLATE = lib
    TARGET =
    DEPENDPATH += .
    INCLUDEPATH += .

    # Input
    HEADERS += libtest.h libtest_global.h
    SOURCES += libtest.cpp
    That is what you should get.

    Regards

  19. #18
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    I now have nearly the same pro file (only some more headers and sources), I have even dropped the double->floats and the opengl support.

    But the lib files are still not generating..


    Edit: I now see, that there is a difference. I have VS 8 (2005, no sp1) and you 7 (afaik 2003). Is that importand?

  20. #19
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    Can you post the code for the library?

    The problem must lie there.

    Regards

  21. #20
    Join Date
    Jul 2006
    Posts
    79
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: project with a dll and a testprog (doesn't compile)

    here you are..
    and thanks for looking into it..
    Attached Files Attached Files

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.