Note that there are some explanatory texts on larger screens.

plurals
  1. POqt add path for 3rd party header and libraries
    primarykey
    data
    text
    <p>I am using qt and developing a desktop app that will run under win xp/vista.</p> <p>I have a 3rd party library UserAgentLib (static, and shared). But I am not sure how to link in qt creator. </p> <p>I have opened the *.pro file and added my library and header path. The library is called UserAgentLib and the header file is called UserAgentLib.h</p> <pre><code>TARGET = Dialer TEMPLATE = app LIBS += D:\Projects\qtDialer\tools\lib\UserAgentLib INCLUDEPATH += D:\Projects\qtDialer\tools\inc SOURCES += main.cpp\ catdialer.cpp HEADERS += catdialer.h FORMS += catdialer.ui </code></pre> <p>I think it does find the header file, as I get about 100 errors for declarations in the UserAgentLib.h file. However, I don't think it is linking with the library.</p> <p>Many thanks for any suggestions,</p> <p>======================</p> <p>I have create a very simple library in VS C++ 2008. Here is the code for the header and source file. Header:</p> <pre><code>// mathslibrary.hpp int add_numbers(const int a, const int b); </code></pre> <p>Source:</p> <pre><code>// mathslibrary.cpp #include "mathslibrary.hpp" int add_numbers(const int a, const int b) { return a + b; } </code></pre> <p>I have compiled this into a library. And tested by linking with a WIN32 console application in VS 2008. The library worked as expected.</p> <p>Now when I try and link with qt.</p> <pre><code>#include &lt;QtCore/QCoreApplication&gt; #include &lt;iostream&gt; #include "mathslibrary.hpp" int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); std::cout &lt;&lt; "add numbers 40 + 60 = " &lt;&lt; add_numbers(40, 60) &lt;&lt; std::endl; return a.exec(); } </code></pre> <p>This is my qmake file:</p> <pre><code>QT -= gui TARGET = testlibrary CONFIG += console CONFIG -= app_bundle TEMPLATE = app LIBS = D:\Projects\TestLibrary\mathsLibrary\Debug\mathsLibrary.lib INCLUDEPATH = D:\Projects\TestLibrary\mathsLibrary\ SOURCES += main.cpp </code></pre> <p>These are the errors I get when I try and build:</p> <p>c:/Qt/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../libmingw32.a(main.o):main.c::-1: error: undefined reference to `WinMain@16'</p> <p>:-1: error: collect2: ld returned 1 exit status</p> <p>And these are the compile issues:</p> <p>Running build steps for project testlibrary...</p> <p>Creating gdb macros library...</p> <p>Configuration unchanged, skipping QMake step.</p> <p>Starting: C:/Qt/mingw/bin/mingw32-make.exe debug -w </p> <p>mingw32-make: Entering directory `D:/Projects/TestQTLibrary/testlibrary'</p> <p>C:/Qt/mingw/bin/mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory `D:/Projects/TestQTLibrary/testlibrary'</p> <p>g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\testlibrary.exe -L"c:\Qt\qt\lib" </p> <p>D:\Projects\TestLibrary\mathsLibrary\Debug\mathsLibrary.lib -lQtCored4 mingw32-make[1]: Leaving directory `D:/Projects/TestQTLibrary/testlibrary'</p> <p>mingw32-make: Leaving directory `D:/Projects/TestQTLibrary/testlibrary'</p> <p>c:/Qt/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../libmingw32.a(main.o):main.c:</p> <p>(.text+0x104): undefined reference to `WinMain@16' collect2: ld returned 1 exit status mingw32-make[1]: <strong>* [debug\testlibrary.exe] Error 1 mingw32-make: *</strong> [debug] Error 2 Exited with code 2. Error while building project testlibrary When executing build step 'Make'</p> <p>Many thanks for any advice,</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload