I am trying to use SQLCipher within my QT C++ project. I am running a windows machine and I have used steps explained in here (until end of step 5) to generate my sqlite3.h, sqlite3.c, sqlcipher.exe and sqlite3.dll. Hopefully, now I have an executable that works fine but I am trying to make use of SQLCipher within my QT project. I want to add sqlite3.h and sqlite3.dll to my project and use its functions to work with databases. I have copied sqlite3.h and sqlite3.dll from sqlcipher-master into my project. My .pro file looks like this:
HEADERS +=\
sqlcipher/sqlite3.h \
myOtherHeaderFiles.\
QMAKE_CXXFLAGS += -DSQLITE_OS_WIN=1 -DSQLITE_HAS_CODEC -DSQLITE_TEMP_STORE=2 -ldl -lpthread
LIBS+="path\to\project\sqlite3.dll"
When I try to build my project no compiling error occurs but when I try to run it I get:
11:55:15: Starting path\to\project\build-project-Desktop_Qt_5_14_1_MinGW_32_bit-Debug\project.exe ...
11:55:15: The program has unexpectedly finished.
11:55:15: The process was ended forcefully.
11:55:15: path\to\project\build-project-Desktop_Qt_5_14_1_MinGW_32_bit-Debug\project\build-project-Desktop_Qt_5_14_1_MinGW_32_bit-Debug\project.exe crashed.
Do I miss something important? Do I copy the wrong files or is there anything more to add to my project before building it? if you have had the experience of using SQLCipher in a QT+mingw project please leave a comment or guide me through.
Related
There are many tutorials about setting up a new XCode project for use with wxWidgets, but I need to integrate it with a large existing XCode C++ project.
The wxWidgets setup process is unclear to me. I built wxWidgets in XCode with the included wxcocoa.xcodeproj file. But when I include all the header files and the libwx_osx_cocoa.dylib library to my existing XCode project, I get all these errors within the wxWidgets header files like Use of undeclared identifier 'wxApp' and No matching constructor for initialization of 'wxEvent' as if it's missing files, but I've included all the header files and compiled library. I tried building wxWidgets in the terminal and get the same errors. I tried make install to actually install wxWidgets on my system. I tried running this command wx-config --cxxflags --libs all in the terminal. I tried adding wx-config --cxxflags and wx-config --libs all to the compiler and linker flags in my XCode project. None of these had any effect.
The irony is that I'm trying to use wxWidgets library to make the GUI process easier, but instead I've spent two days pulling my hair out trying to get my C++ XCode project to compile. Does anyone know what I'm doing wrong?
EDIT: The problem seems to be XCode. I've downloaded the wxWidgets Hello World sample program at the bottom of this page. I can build this program without issue in the terminal, but when I put it into a new XCode project, it won't build. How can I get XCode to build this simple program?
cx-config output:
XCode project settings:
EDIT 2: I exported the Build Log out of XCode and saw that the actual build command uses clang. When I successfully compile Hello World in the terminal, I use clang++. When I try the same command with clang, it doesn't work. Perhaps this is the issue, since clang only links C libraries and the errors XCode is giving me relate to not being able to find standard C++ functions.
EDIT 3: Wow I hate XCode. I got my Hello World program to compile by accident. The solution was putting the wxWidgets compiler flags in the Targets Build Settings, whereas before, I had it in the Project Build Settings. I assumed the Targets would inherit the Project settings, but I guess not!
EDIT 4: I got my complicated XCode project to compile with the wxWidgets libraries by taking all the search paths & flags and moving them from the Project Build Settings to the Targets Build Settings. What a nightmare! Glad it's over
#WaddleDee72
,
I suggest doing following:
Delete wxWidgets directory.
Unpack wxWidgets into i.e. ~/wxWidgets.
Open Terminal.
In the Terminal
4a. cd ~/wxWidgets
4b. mkdir buildOSX
4c. cd buildOSX
4d. ../configure --enable-debug
4e. make -j5
After successful build
wx-config --cxxflags
wx-config --libs
Use the output of 2 commands above and put the values where they belong in XCode project.
If you get any issues - let us know.
Thank you.
I have made my wxwidgets project in codeblocks, I need a way to run my GUI directly like most applications run on a PC(like calculator , calender etc..). I don't want to go to codeblocks and build & run my program again and again. I need to make an exe file to just run it by clicking and my GUI directly starts running.
If you have already compiled your code, an executable file can be found in the output folder. With that file, u can execute your code directly without any build, because the code has already been built.
I'm using g++ as the compiler on WSL, for me I do this:
g++ MyApp.cxx `wx-config --cxxflags --libs` -o MyApp.exe
then I run it like all other apps.
I'm having trouble deploying .exe generated with QtCreator on Ubuntu 14.04. I got several versions of qwt installed (and i need those, one compiled with qt4 the other with qt5).
Problem is, i don't know why but Qt seems to link the wrong version of qwt to my .exe whatever i do .. When i use LDD on my .exe, it always show /usr/lib/libqwt.so.6. Thing is i'm linking the version i need in my .pro like this :
LIBS += -L/usr/local/qwt-6.1.2/lib/ -lqwt
And in project configuration i set LD_LIBRARY_PATH with /usr/local/qwt-6.1.2/lib
Still my .exe doesn't link to the right library.
Any idea why and how to fix this ? It causes segmentation fault on launch of course as my program is compiled with qt5 and not qt4..
Thanks in advance
You can try adding a runtime path to the linker flags. In your .pro file you can add the following line (Its probably worth printing your QMAKE_LFLAGS in your pro file as well):
QMAKE_LFLAGS += "-Wl,-rpath,/usr/local/qwt-6.1.2/lib/"
message ("QMAKE_LFLAGS = $$QMAKE_LFLAGS")
Re-compile and then run ldd again. During runtime also ldd) your program should now point to this location first.
Note
This is assuming that you are using a gnu compiler!
I sorted out my problem, seems like settings the environment variables in QtCreator is not enough. You have to do it in the terminal aswell before launching the .exe, that was my bad.
Just had to set LD_LIBRARY_PATH correctly.
I need to ship a product with shared libraries (Ubuntu) in a folder I've created ('shared') within the project directory--i.e., shared libraries that are not in /usr/lib, /usr/local/lib, etc. To this end I've done this in the .pro file, i.e.
LIBS += -Lshared/gsl -lgsl -lgsl_cblas
NB the executable is in the same directory asy the 'shared' folder. Everything works when I launch the program in debug mode from QtCreator. In addition the program fails to launch if I remove or rename the libs in 'shared', and also I've verified that the app is not finding these libraries anywhere else. But when I launch from the command line, I get
error while loading shared libraries: libgslcblas.so.0: cannot open
shared object file: No such file or directory
What's going on?
EDIT: The solution is a variation on lionbest's below, as developed in the comments. For some reason, it turns out that on my platform qmake/QMAKE_FLAGS only allows a specific format for linker options, and not the one you find googling around for other instances where people have worked with QMAKE_FLAGS. Namely,
QMAKE_FLAGS += "-Wl,-rpath,\'\$$ORIGIN/shared/gsl\'"
QMAKE_LFLAGS_RPATH=
Specifically, the problem was that the parser (or linker) would not accept -rpath=..., despite the fact that this seems to work for everyone else. Ubuntu 12.04, gcc 4.6.3, Qt 4.8.0, QtCreator 2.4.1 "based on Qt 4.7.4". Hope this experience can save someone else the same frustration.
Start a program with environmental variable LD_LIBRARY_PATH=shared/gsl or add a RPATH to linker settings:
LIBS += -Wl,-rpath=shared/gsl
If you want to make shortcut for your application, most distribution (based on Gnome, KDE, LXDE and XFCE) use a .desktop file. QtCreator probably generated one for you. You need to edit it or generate it, and put to $HOME/.local/applications or /usr/share/applications/ during installation. In desktop file you could add envirometal varible and starting directory as follow:
Exec=/usr/bin/env LD_LIBRARY_PATH=/<path_to_libs>/ /<path>/app -extra_options
If you need to run your application in specific directory add line:
Path=/<path_to_your_application_working_dir>
You can use ${} inside path.
I've heard that it is possible to build non-Qt applications (like simple C++ HelloWorld) with Qt Creator. I downloaded and installed Qt Creator, and tried to compile simple code with it. But I didn't succeed: Creator needs qmake to create makefile.
Although the package I downloaded includes MinGW, there is no qmake inside of it.
I still want to use it just like an IDE to create simple C++ sources and compile them with MinGW. Is it possible to use Qt Creator without installing whole platform?
Qt Creator support CMake projects, you just need to choose Open a file or project and select the root CMakeList.txt of your project.
If you want to define your own build workflow, you can remove the default build step and create your own custom build steps (Qt Creator Build Steps).
I think you can modify the build step to remove qmake and use your custom make file.
You totally can!
You can write a .pro file yourself and use it as a project file to use QtCreator without linking / using any of the Qt libraries.
In Project / Compilation Parameters, you can actually tune the compilation steps (removing the qmake step and adding your own).
I use it for a big project of mine and it's very efficient: QtCreator's C analyzer is diamond.
Here's a sample project file for me:
TEMPLATE = app
TARGET =
DEPENDPATH += . include
INCLUDEPATH += . include
# Input
HEADERS += include/x.h \
include/y.h \
include/z.h
SOURCES += src/x.cpp
Note that I actually use qmake to generate this file automatically, but you can also put your hands into it and modify it by hand.
Afterwards, it's only a matter of $ qtcreator yourfile.pro.