How can I quickly import files from another project??
-
Hi, good evening.
I already tried to include the absolute path of the project (plus headers and .cpp) but it doesn't work. I also tried to include files from the main.cpp file, nothing.. Could you kindly help me? -
Hi and welcome to devnet,
What are you using qmake ? cmake ? Do you want to rebuild these files ?
-
Hi!
Yes, I'm using qmake under Qt Creator. -
Then, the second question: do you want to rebuild these files in your new project ?
-
Oh, I'm sorry. Yes I want.
-
Then the quick and dirty way to do this is:
SOURCES += /path/to/your/other/project/cpp_file.cpp INCLUDES += /path/to/your/other/project/header_file.h
-
Already tried, but it was occurred an issue:
:-1: error: No rule to make target
../Library/Lib/mathfuncslib.cpp', needed by
mathfuncslib.o'. Stop. -
Can you show your pro file ?
-
This post is deleted! -
I'm sorry:
QT = core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
SOURCES += ~/Library/Lib/mathfuncslib.cpp
INCLUDES += ~/Library/Lib/mathfuncslib.h
SOURCES +=
main.cppBut I get the same result..
-
I'd rather go with an absolute path
-
Unfortunately it's the same.
-
Which version of Qt are you using ?
-
5.4 version
-
Did you re-run qmake ?
-
Yes I did!!
-
Ok! The path was wrong!
Now, I have to include the file in the main also? If yes, I have to use the absolute path? -
You can use them as normal. You need to update
INCLUDEPATH
to also contain the folder where the headers are located.