how can I change Qt install path after I building it ?
Example : qmake.exe search binaries to original install path, how can I change/redefine it ?
Thanks.
Edit : I finally found this patch to apply to Qt :
http://ftp-developpez.com/qt/binaires/win32/patcher/QtPatcher.7z
http://ftp-developpez.com/qt/binaires/win32/patcher/QtPatche_src.7z
I was looking into this and found a way that works (in qt 4.7.2) by customizing qt with a qt.conf file.
In my case, I added a qt4-4.7.2/bin/qt.conf (I think it must be in the same place as the qmake executable)
With the following contents:
[Paths]
Prefix = c:/my_path/to/qt4-4.7.2
and the qmake -query started returning the proper paths!
See: http://qt-project.org/doc/qt-5.0/qtdoc/qt-conf.html for more details
You can change path to binaries and many other hardcoded paths in qmake using qmake -set command.
See Configuring qmake's Environment for details.
I can answer it for windows, not so sure about others. Remove the path variables if any present in the environmental variable PATH.
In Qt-Creator goto,
Tools->Options->Qt4->Qt Versions
In the right hand side area, you will find Auto- Detected and Manual. Under Manual add a new entry by clicking the + symbol in the far right. Specify the QMake location by clicking Browse . Change the Default Qt Version to your newly specified Version. Of course, you have to re -build the application. Hope that it helps.
On Unix/Linux:
You can also use LD_LIBRARY_PATH+PATH for workarounds. But still, some defaults are hardcoded in the code, yes. A rebuild is a must.
On unix you can make a symbolic link, otherwise you probably need to rebuild it
This worked for me with Qt 5.15.2:
cd ~/Qt/Tools/QtCreator/share/qtcreator/QtProject
grep -inr '<olduser>' | cut -d: -f1 | xargs sed -i 's/<olduser>/<newuser>/g'
Replace <olduser> and <newuser> obviously.
Related
I am developing a project in QT, when I want to use Windeployqt to wrap my exe.
error:Warning: Unable to read \mkspecs\qconfig.pri comes out
I execute Eindeployqt in "QT5.1.1 for Desktop(Mingw 4.8.3)", I checked the qconfig.pri exsited in
C:\Qt\Qt5.1.1\5.1.1\mingw48_32\mkspecs\qconfig.pri
I have added environment variable, can anyone help on this?
Usually you would do this with environment variable
QMAKESPEC=C:\SOMEPATH\qt\mkspecs\win32-g++
or in your case probably:
QMAKESPEC=C:\Qt\Qt5.1.1\5.1.1\mingw48_32\mkspecs
though normally it should be a folder below mkspecs specifying your platform (win32-g++ in my first example).
The windeploy tool will use the paths provided from qmake.
Assuming that you are in the bin folder of your qt installation.
All "important" paths can be seen with:
qmake -query
In your case you will see that all paths have the wrong location.
You have to add a qt.conf file.
https://doc.qt.io/qt-5/qt-conf.html
with the following content:
[Paths]
Prefix = ..
Now, running qmake -query should return correct paths. Also the windeploy tool should be able to find the correct paths.
I just installed ahven, but if I compile a testprogram with Ahven.Framework,
I always get a compiler error:
file "ahven.ads" not found
My files for ahven are just here:
/opt/ada/include/ahven/ahven.ads
/usr/share/ada/adainclude/ahven/ahven.ads
how can I tell gnat where to search?
Edit:
I'm using gnatmake on Linux, without any project file.
There's an ahven.gpr file, which should take care of the dependencies. Find where that file was placed, and then either add a reference to it in your project's .gpr file, or if you're using the gps IDE, right-click on the project name, select Project/Dependencies, and then do "Add From File".
Assuming you are using gnatmake and a unix/linux based system, You need to add a path to your gnatmake command. To look up how to do this type gnatmake and look for the -I option in the help screen that follows. Im not sure which one of your dirs would be appropriate to include. That should be found in your ahven documentation.
I've been reading for a couple days on how to copy/update external resources, plugins or frameworks to my App's Mac Bundle using Qt creator or qmake.
Right now I have found two main solutions. One is to use qmake together with some commands on the ".pro" file. The other one is to do a "Custom Deployment Step" script.
I was hoping to use the second option cause I already had a small make script that did what I wanted. The problem is that Qt Creator offers so little variables to work with that the script lost its usefulness. For instance, my script uses the "Target App Path" as a parameter so it can do all its work from there. But please correct me if I'm wrong, Qt Creator only offers %{buildDir} and %{sourceDir} variables...
The other option is using qmake. These are the things that I have tried so far on my ".pro" file:
1) Using the INSTALL command. I did a small test where I tried copying some files this way:
MediaFiles.path = test/media
MediaFiles.files = media/*
INSTALL += MediaFiles
And basically nothing happend. I was hopping to find the same "media" folder on the "test" folder but nothing. Don't know if I'm doing something wrong.
Please note that the "media" folder is beside the "test" folder and the ".pro" file. (They all have the same hierarchy position.)
2) Then I tried QMAKE_BUNDLE_DATA:
MediaFiles.path = Contents/MacOS
MediaFiles.files = media/*
QMAKE_BUNDLE_DATA += MediaFiles
But this gave me the following error:
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
make: *** [PathToApp] Error 64
None of the solutions seem to be pleasing so far. If I wanted to do a good custom make script I will need to hardcode every target path separately. In my case I have 8 different target path depending on some "CONFIG" variables.
I'm sure the qmake solution are the official way of doing this. If someone can point me out the solution to the Error 64 would be cool.
Some further question:
Do I have to do a qmake every time I want to update my bundle?
Can I execute my make script with the qmake?
QMAKE_BUNDLE_DATA started working flawlessly after putting the command on the end of the .pro script.
mac{
MediaFiles.files = media
MediaFiles.path = Contents/MacOS
QMAKE_BUNDLE_DATA += MediaFiles
}
This is my first try with cmake and I would like to have, if possible, some feedbacks about what I did since some problems remain.
In the CMakeLists.txt of the library folder, I created two makefile targets: configure-antlr3c and antlr3c. The first target runs the autotools configuration shell script, the second one runs the make executable to build the library:
# CMakeLists.txt in libantlr3c-3.1.3
add_custom_target(
configure-antlr3c
${SHELL_EXECUTABLE} configure
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(
antlr3c
${MAKE}
DEPENDS configure-antlr3c
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
The main problem is thatconfigure-antlr3c target is always "out of date", so it will always be executed even if no changes happened. Moreover, I necessarily need to generate my cmake makefiles in a separate directory (not in the root directory of my project) to avoid overriding the autotools Makefile of the library...
Has anyone had this problem (building autotools projects with cmake) ? And if so, what have been your solutions ?
Thank you.
EDIT : Solution
In the root CMakeLists.txt:
include(ExternalProject)
ExternalProject_Add(
libantlr3c
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/libantlr3c-3.1.3
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/lib/libantlr3c-3.1.3/configure --prefix=${CMAKE_CURRENT_SOURCE_DIR}/lib/libantlr3c-3.1.3
PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/lib/libantlr3c-3.1.3
BUILD_COMMAND make
BUILD_IN_SOURCE 1
)
I think that you'd be better off using the ExternalProject feature of cmake. I guess you have your project and have libantrl in a sub directory?
project
+- libantlr
+- mysrc
---- etc ----
If that's the case, you can do something like this in the top level CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project(test)
include(ExternalProject)
ExternalProject_Add(libantlr
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libantlr
CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/libantlr/configure --prefix=<INSTALL_DIR>
BUILD_COMMAND ${MAKE})
The <INSTALL_DIR> is expanded to something like libantlr-prefix, so things are installed in your build tree rather than in /usr/local, which is what autotools would do without a prefix.
I needed to do something similar but found it surprisingly difficult to get a working solution, despite the example provided here with the accepted answer, and code snippets provided in several other blog posts, the CMake support email listserv archives, etc. For the benefit of others who come across this question, here is my solution.
The external project we wanted to use is libmodbus, though I believe my solution is general enough to work with any project configured with the standard autoconf recipe of ./autoconf.sh && configure.sh && make && make install.
We wanted to add libmodbus as a submodule of our git repository. We added to our repository at the path <root>/opt/libmodbus. The CMake code to configure it is located in <root>/cmake/modbus.cmake, which is included from our root CMakeLists.txt using
# libmodbus
include(cmake/modbus.cmake)
The content of cmake/modbus.cmake is:
include(ExternalProject)
set(MODBUS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/opt/libmodbus)
set(MODBUS_BIN ${CMAKE_CURRENT_BINARY_DIR}/libmodbus)
set(MODBUS_STATIC_LIB ${MODBUS_BIN}/lib/libmodbus.a)
set(MODBUS_INCLUDES ${MODBUS_BIN}/include)
file(MAKE_DIRECTORY ${MODBUS_INCLUDES})
ExternalProject_Add(
libmodbus
PREFIX ${MODBUS_BIN}
SOURCE_DIR ${MODBUS_DIR}
DOWNLOAD_COMMAND cd ${MODBUS_DIR} && git clean -dfX && ${MODBUS_DIR}/autogen.sh
CONFIGURE_COMMAND ${MODBUS_DIR}/configure --srcdir=${MODBUS_DIR} --prefix=${MODBUS_BIN} --enable-static=yes --disable-shared
BUILD_COMMAND make
INSTALL_COMMAND make install
BUILD_BYPRODUCTS ${MODBUS_STATIC_LIB}
)
add_library(modbus STATIC IMPORTED GLOBAL)
add_dependencies(modbus libmodbus)
set_target_properties(modbus PROPERTIES IMPORTED_LOCATION ${MODBUS_STATIC_LIB})
set_target_properties(modbus PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${MODBUS_INCLUDES})
A component that uses libmodbus can declare its dependency as usual:
add_executable(hello_modbus main.cpp)
target_link_libraries(hello_modbus modbus)
A few notes:
This abuses the DOWNLOAD_COMMAND to perform the autogen.sh step. The git clean -dfX is probably not necessary (it is a leftover from an earlier version that used the BUILD_IN_SOURCE option. If you really want to download the code instead of using a git submodule, you'll need to modify this line appropriately.
We go to the trouble to force a static-only build of the library. Adjust your configure command line if you want shared libraries.
The set_target_properties command to set the IMPORTED_LOCATION will fail without the BUILD_BYPRODUCTS ${MODBUS_STATIC_LIB} declaration.
Likewise, the set_target_properties command to set the INTERFACE_INCLUDE_DIRECTORIES will fail without the file(MAKE_DIRECTORY ${MODBUS_INCLUDES}).
I'm looking for the equivalent to ./configure --prefix= for qmake. Basically, I want to override the default install/deployment directory. How is this specified with command line qmake? I also use QtCreator to build a lot of my gui projects, and I'd like to know how to do the same thing while building inside of QtCreator. Is there a variable that I can manipulate in the .pro files to do this, or do I change my project settings?
Thanks!
For me, it seems that qmake PREFIX=/usr/local doesn't work
(try with the source of qtcreator)
So the solution is to use qmake normally, but then, you do
make
INSTALL_ROOT=/usr/local make install
I've found the solution to this, and it is just as easy as specifying the --prefix option to configure.
For qmake on the command line, you simpy add a PREFIX= parameter:
qmake PREFIX=/usr/local
There are two ways to do this in QtCreator. First, you could change your .pro file to include an explicit PREFIX variable definition. However, this is not recommended, as the prefix is a preference specific to each user, and it is preferable to keep the distributed project files generic. A better way to do this, is in your own project settings. Simply go to the build configuration that you are using, expand the qmake settings, and add PREFIX= to the additional arguments.