×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    4

    Exclamation Adding include paths to QT Creator project

    I'm using QT Creator, and I admit that I've never used an IDE for programming before. I'm using OpenCV libraries, and have them installed in C:\Program Files\OpenCV1.2\include\opencv

    I started with a simple command line project, and tried to include highgui.h (which lives in the OpenCV directory mentioned above). If I include the whole filename, like #include "C:\...\highgui.h", I assume that it fails to then find other files highgui.h itself includes.

    I then added INCLUDEPATH += C:\Program Files\OpenCV1.2\include\opencv to the project file. Didn't help. Building still gives "highgui: no such file or directory".

    I added C:\Program Files\OpenCV1.2\include\opencv to the system path, and verified that it shows up in the environment variables of QT Creator's build configuration. I also opened a command line, and verified it was in the path. Still get the "highgui: no such file or directory" error.

    I tried including it with several different syntax, which I admit I don't fully understand the difference between, such as #include <highgui>, #include "highgui.h", etc.

    Can someone help me understand how to get QT Creator to see these third party library paths?

  2. #2
    Registered User
    Join Date
    Sep 2009
    Posts
    4

    Re: Adding include paths to QT Creator project

    Ok, so I found part of the problem. It couldn't handle the space between Program and Files. It was passing into the compiler something like... -I "C:\Program" "Files\...

    No I think it is successfully including the .h file now, because I'm no longer getting that error.

    However, I'm still getting "undefined reference to" function names that are in the .h.

  3. #3
    Registered User
    Join Date
    Sep 2009
    Posts
    4

    Re: Adding include paths to QT Creator project

    Compiler output (I'm probably just too inexperienced to know that I'm doing something wrong):

    Running build steps for project Example1...
    Starting: C:/Qt/2009.03/mingw/bin/mingw32-make.exe clean -w
    mingw32-make: Entering directory `C:/Users/kimble/Documents/FolderShare/QT Projects/Example1'
    C:/Qt/2009.03/mingw/bin/mingw32-make -f Makefile.Debug clean
    mingw32-make[1]: Entering directory `C:/Users/kimble/Documents/FolderShare/QT Projects/Example1'
    del debug\main.o
    mingw32-make[1]: Leaving directory `C:/Users/kimble/Documents/FolderShare/QT Projects/Example1'
    C:/Qt/2009.03/mingw/bin/mingw32-make -f Makefile.Release clean
    mingw32-make[1]: Entering directory `C:/Users/kimble/Documents/FolderShare/QT Projects/Example1'
    del release\main.o
    Could Not Find C:\Users\kimble\Documents\FolderShare\QT Projects\Example1\debug\main.o
    mingw32-make[1]: Leaving directory `C:/Users/kimble/Documents/FolderShare/QT Projects/Example1'
    mingw32-make: Leaving directory `C:/Users/kimble/Documents/FolderShare/QT Projects/Example1'
    Could Not Find C:\Users\kimble\Documents\FolderShare\QT Projects\Example1\release\main.o
    Exited with code 0.
    Configuration unchanged, skipping QMake step.
    Starting: C:/Qt/2009.03/mingw/bin/mingw32-make.exe -w
    mingw32-make: Entering directory `C:/Users/kimble/Documents/FolderShare/QT Projects/Example1'
    C:/Qt/2009.03/mingw/bin/mingw32-make -f Makefile.Debug
    mingw32-make[1]: Entering directory `C:/Users/kimble/Documents/FolderShare/QT Projects/Example1'
    g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_THREAD_SUPPORT -I"c:\Qt\2009.03\qt\include" -I"c:\Progra~1\OpenCV1.2\include\opencv" -I"c:\Progra~1\OpenCV1.2\bin" -I"c:\Qt\2009.03\qt\include\ActiveQt" -I"debug" -I"c:\Qt\2009.03\qt\mkspecs\win32-g++" -o debug\main.o main.cpp
    g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\Example1.exe debug/main.o -L"c:\Qt\2009.03\qt\lib"
    mingw32-make[1]: Leaving directory `C:/Users/kimble/Documents/FolderShare/QT Projects/Example1'
    mingw32-make: Leaving directory `C:/Users/kimble/Documents/FolderShare/QT Projects/Example1'
    debug/main.o: In function `main':
    C:/Users/kimble/Documents/FolderShare/QT Projects/Example1/main.cpp:4: undefined reference to `cvLoadImage'
    C:/Users/kimble/Documents/FolderShare/QT Projects/Example1/main.cpp:5: undefined reference to `cvNamedWindow'
    C:/Users/kimble/Documents/FolderShare/QT Projects/Example1/main.cpp:6: undefined reference to `cvShowImage'
    C:/Users/kimble/Documents/FolderShare/QT Projects/Example1/main.cpp:7: undefined reference to `cvWaitKey'
    C:/Users/kimble/Documents/FolderShare/QT Projects/Example1/main.cpp:8: undefined reference to `cvReleaseImage'
    C:/Users/kimble/Documents/FolderShare/QT Projects/Example1/main.cpp:9: undefined reference to `cvDestroyWindow'
    collect2: ld returned 1 exit status
    mingw32-make[1]: *** [debug\Example1.exe] Error 1
    mingw32-make: *** [debug] Error 2
    Exited with code 2.
    Error while building project Example1
    When executing build step 'Make'

  4. #4
    Regular Contributor
    Join Date
    Mar 2009
    Posts
    430

    Re: Adding include paths to QT Creator project

    Undefined reference means that the linker is missing symbols. That means that it cannot find the function "body" of a method. Your first problem was that it could not find the "headers", now you gave the headers and you are one step further. Undefinied reference technical means that you are missing the actual implementation of the method. This can happen in the following cases:

    • You missed the function body in your implementation
    • You missed to include the cpp file that contains that function
    • You missed to link against the library that contains the function.


    I think in your case it is the last case. Add the library to your Qt project file:

    LIBS += -l<libname>

    Try wheter you have to give the libname with or without extension.

  5. #5
    Registered User
    Join Date
    Sep 2009
    Posts
    4

    Re: Adding include paths to QT Creator project

    Thanks, I added the LIBS for each of the libraries. It compiles now.

    Does anyone know where there is a tutorial about libraries, linkers, etc. that I could learn more about how all this works. They never teach you this practical knowledge in school.

  6. #6
    Regular Contributor
    Join Date
    Mar 2009
    Posts
    430

    Re: Adding include paths to QT Creator project

    Well my first C++ Book told me about compilers and linkers but I was not interested in it. I wanted to show a window on the screen and did not care for the background then.

    Usually if you are a beginner you make every possible misstake one time and learn from it. If you got that now, there is not so much left that you have to know: The difference between a static and a dynamic library and possible the common command line arguments for the GCC-compiler how to pass include paths, library paths and actual libraries.

Similar Threads

  1. Qt for Symbian development resources
    By liuxg in forum [Archived] Qt General ( Qt技术)
    Replies: 55
    Last Post: 2011-01-26, 04:06
  2. How to Create multiple selection listboxes
    By somnathbanik in forum Symbian
    Replies: 8
    Last Post: 2009-07-10, 12:27
  3. Application Flow Problem...!
    By damodharan in forum Symbian
    Replies: 2
    Last Post: 2008-11-19, 10:24
  4. Problem to compile series60 3rd
    By asmobease in forum Symbian
    Replies: 9
    Last Post: 2006-09-04, 15:15
  5. Error : Too many include paths! Please reduce the number of include paths or ....
    By npr.novo in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 8
    Last Post: 2006-02-06, 21:42

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×