I've searched this for a while and haven't found anything answered anywhere:
I have a project in QtCreator that has no compilation errors, and runs fine as a normal C++ project in Eclipse.
However, when I try to run it as a Qt app, it says it could not find an executable and I need to specify one.
As many other sites have suggested, I have searched the directories for the .exe that QtCreator was supposed to make (according to the other sites), but I am yet to find anything.
I'm in no rush, but have spent a long time on this and would like to move on to actually writing the Qt part.
Thanks in advance.
Are you still struggling with the solution ? The most easy solution is, restore default setting by deleting file QtCreator.ini. After that configure project once again by giving build directory path. If you are working on Linux system, run following command to find QtCreator.ini file.
$ locate QtCreator.ini
It will give ouput like this
/home/tan/.config/QtProject/QtCreator.ini
Then delete the file on obtained path using following command
$ sudo rm -f /home/tan/.config/QtProject/QtCreator.ini
Now open project once again and configure with your desired build and run settings.
Upvote if above solution helps you. Btw if I've made any grammatical mistakes, I am sorry for my english. :)
Best luck !!
I'm not sure I understand what you mean by having a QtCreator project and running it in Eclipse or running it as a Qt App but if you are looking for an exe file, QtCreator is probably configured to do shadow builds for your project. This means that build output is sent to a directory outside of your project source directory. If your project is in a directory called MyApp, then look for a directory beside it called MyApp-build-desktop. You should find your executable in there.
Related
I'm pretty new with C++ development, and I wanted to use an IDE. I downloaded codelite, and everything was working fine.
The issue
Recently I started development an App for the NetworkSimulator3 or Ns3, that runs with Waf(https://waf.io/). Using the codelite just for my app, and doing the build&Run on the terminal with waf seems wrong.
In the end, codelite is not recognizing a butch of files of ns3, and keep pointing errors.
What I tried to do
I tried adding all Ns3 files in a single workspace, together with my app files, in hopes that everything would work. Instead I still got a bunch of "No such file or directory" errors, although these files exist and are added on the IDE
On the import, Ns3 demands us to call it like this:
#import <ns3/packet.h>
Although the .h is inside another folder:
src/network/model/packet.h
There are a few wscripts files that probably work on these bindings, although I'm not 100% sure.
So I also tried:
Adding the .h in the same folder of my app
Creating a new virtual folder called ns3, and adding the headers there
Including the folder with the headers in the compiler's include paths
Including the folder with the headers in the linker like it was a library
Nothing worked so far
I just wanted to open the Ns3 on an IDE so I could work without several errors showing. Maybe even with some autocomplete?
Could you guys help me figure this out?
Edit
I also added a "Custom build", so I can execute and build my project using waf, but the IDE errors didn't disappear
On the import, Ns3 demands us to call it like this: #import <ns3/packet.h> Although the .h is inside another folder: src/network/model/packet.h
Headers imported with <ns3/header.h> are copied from src/module/(model/helper) to build/ns3 when you build ns-3. You need to add build/ as an include folder (e.g. -I/path/to/ns-3-dev/build), which will make <ns3/header.h> work correctly.
Not sure on the other issues, since I've never tried CodeLite.
I just wanted to open the Ns3 on an IDE so I could work without several errors showing. Maybe even with some autocomplete?
If I may recommend, try the CMake buildsystem. Clone the code and create a cmake cache folder (e.g. mkdir cmake_cache), then generate the CodeLite project (e.g. cd cmake_cache && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -G "CodeLite - Ninja" .., or -G "CodeLite - Unix Makefiles") and then open the project in cmake_cache with CodeLite. :)
Update: just read on their blog that exporting compile commands is required for code completion when using cmake.
https://codeliteide.blogspot.com/2014/02/codelite-ide-60-cmake-and-clang-code.html
I'm using Ubuntu and I have written my c++ code in Eclipse Neon.
My workspace contain 4 projects. The main project is called BaseCppProjectRun (it contains main.cpp file) and I have other projects with these names: Encoders, frmwrk, NetworkLayer - the BaseCppProjectRun using each one of them.
If I running my program directly from eclipse everything works.
But I want to running my program from terminal - and I can't.
Because When I'm trying to run my progrm like this:
root#ubuntu:/builds/BaseCppProject/BaseCppProjectRun# ./Debug/BaseCppProjectRun
I'm getting this error:
./Debug/BaseCppProjectRun: error while loading shared libraries: libfrmwrk.so: cannot open shared object file: No such file or directory
As I said before, if I'm running it directly from eclipse everything works.
How can I run my program from terminal?
How is Linux supposed to know where to find libfrmwrk.so, if you don't put that either where it normally looks nor tell it where it can be found.
Eclipse seems to set up the paths the runtime linker looks into so, that when your program is loaded, the runtime linker knows where to find your libfrmwrk.so and so on.
You'll either have to
install these libraries (.so's) so that they are found in default locations, or
set LD_LIBRARY_PATH to contain all the folders to look into.
I haven't worked with Eclipse CDT in ages, but you can by now probably export some project formats that allow you to easily install things.
Another thing: It seems you're running software you're still debugging as root: That is a terrible idea, and if it can be avoided, avoid it.
I finally figure it out!
Refere to Marcus Muller's answer + my steps this is how I have fixed it ( all steps via terminal):
Create new directory in my workspace directory and called it libs.
In each one of your projects do: right click > c/C++ Build > Build Steps (tab) and in Post-build steps paste this:
cp ${BuildArtifactFilePrefix}${BuildArtifactFileName} "${WorkspaceDirPath}/libs/"
This code copy the so files directly into your libs directory when you compile your program.
And finally, in your terminal execute this:
export LD_LIBRARY_PATH=/builds/BaseCppProject/libs/
Now you can run your program via terminal.
I'm trying to create an executable from my SDL2-Project, which will run on any Mac that I send it to.
My Program is written in C++, Xcode9.2
Apparently the way to go in XCode is Project->Archive. This works perfectly fine as long as I execute the product on my mac. On a mac that does not have the SDL2.framework installed under /Library/Frameworks/ it throws following error upon execution:
dyld: Library not loaded: #rpath/SDL2.framework/Versions/A/SDL2
Referenced from: /Users/thomas/Downloads/Chat_Program_Mac v1/Chat_Program 2
Reason: image not found
So this error is not very surprising, as I haven't linked statically (wouldn't know how this works anyways) and obviously the program needs the framework(s) to run.
On Windows you simply put the .dll files in the same folder as the .exe and that works.
Now on mac, putting the frameworks in the same folder as the executable won't change anything.
From my research I know, that in XCode under BuildSettings->"Framework Search Paths" there is the option to tell the compiler where to look for the frameworks.
Someone on this forum answered to a similar question to put ./ as search path and set it to recursive to let the compiler look for the frameworks in the same folder, where the executable is.
This somehow got me closer to the solution. During the build process XCode now looks for the frameworks inside the debug folder and creates the executable without error, while there are no SDL frameworks in /Library/Frameworks/.
EDIT: this does not work for Project->Archive. Even though I put the frameworks into the release folder. (/Users/Tim/Library/Developer/Xcode/DerivedData/Chat_Program-gapnuzuivnylrgbubtywdbzshous/Build/Products/Release)
When I try to run the executable though, the same error appears saying the library couldn't be loaded.
The executable does run though, if I put the frameworks back into /Library/Frameworks/, which tells me there must be an option to tell XCode where the executable has to search for frameworks, that is not the BuildSettings->"Framework Search Paths" of the project.
So how do I tell my executable to look for the framework inside it's own folder?
So here's how I solved my problem:
Goto BuildSettings->All->Linking->Runpath Search Paths
Change to "#loader_path/"
Apparently this changes #rpath in the error message above to the path where the executable is, so the framework(s) can now be put into the same folder as the executable.
Pretty simple actually, maybe I'm an idiot that I had to research a whole day to find this. Maybe it's just very well hidden and kept as secret as possible even on the internet...
Whatever - happy it works now :)
I recently installed MinGW on my 64-bit Windows 7 computer and when I attempt to compile the most basic of c++ programs, for example
#include<iostream>
using namespace std;
int main()
{
cout << "Hello World" << endl;
return 0;
}
I get the error that "The program can't start because libgmp-10.dll is missing from your computer."
Have you tried adding C:\MinGW\bin as a System variable Path (not PATH) in Settings->System Properties->Environment Variables?
I saw this solution on this page: Missing libgmp-10.dll
Go to the mingw download page and browse the following directories:
MinGW / Base / gmp / gmp-5.0.1-1
Currently you end up with the following link:
http://sourceforge.net/projects/mingw/files/MinGW/Base/gmp/gmp-5.0.1-1/libgmp-5.0.1-1-mingw32-dll-10.tar.lzma/download
and it contains the needed file.
I know there are automated methods for installing mingw gcc, but when one uses single mingw packages, then gmp is one of obligatory downloads.
added
c:/MinGW/bin to PATH
and restarted CMake-gui
worked for me
I came upon this question when I started CodeBlocks and then clicked on my project. After the project notes appeared and I pressed OK, the error appeared:
"System Error: The program can't start because libgmp-10.dll is missing from your computer.
Please reinstall the application to fix this problem."
I presse OK a bunch of times and then was able to do normal compile, link, etc. but that error showed up everytime I started C::B and went to the project. Then I noticed that the LLVM Clang compiler was my default compiler in the compiler settings, though GCC was set as the compiler specific to the project I was working on.
The solution was to set the compiler in the compiler settings to GCC (mingw) and also set it as the default compiler. After that this system error stopped popping up every time I started the project.
The reason I posted this answer is because it answers the OP's question and other people with the same question may have a similar reason for this irritation, and my personal experience in this matter may prove useful to those people.
If you did not find this file in your installation directory, and then went to the site [Click here] to download the file, and then extract it to your installation directory.enjoy:-)
Caution - removing stuff from your path can compromise your system!
Interestingly, you not only need to add the MinGW bin to your Path, but also you need to make sure that certain things are not on your path*. In my case, I saved my entire path variable as a backup, deleted everything non-system from my path except for MinGW and CMake, leaving:
C:\MinGW\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files (x86)\CMake\bin
You should use the appropriate elements from your system path.
I first tried to do this with a batch job that launched CMake, but it seems that the CMake GUI was reaching back and grabbing the System 'Path' variable instead of the command prompt 'Path' variable, which I had printed and confirmed was as listed above before launching CMake.
Incidentally, I backed up the entire Windows VM before starting!
* For instance: various references, including known issues, mention sh.exe. I inherited this VM from my client and hacked it up further, so it's easier for me to use a clean path for my cross-compiling task and return afterward...
In just installed MinGW using the mingw-get-setup.exe v0.6.2beta-20131004-1 installer. Even though during the install I selected the gcc package, the installer didn't include the "mingw32-gmp" package, which includes libgmp-10.dll. I had to rerun the installer, chose the "Reinstall" option, and manually select the "mingw32-gmp dev" package.
If you don't have the permission modifying your global path, you can also change the active directory of your cmd shell.
How to do it (in the cmd shell):
C:\> cd C:\MINGW\bin
C:\MINGW\bin> gpp.exe C:\Users\James\Desktop\Program.cpp
How it doesn't work:
C:\>C:\MINGW\bin\gpp.exe C:\Users\James\Desktop\Program.cpp
Note: you have to change "C:\Users\James\Desktop\Programm.cpp" to wherever your program lays
How it works: windows looks for needed DLLs while in the same directory and if it can't find it there it'll look in the PATH variables (so it will search system32 by default), if you add any missing DLLs to the directory from where you run it, windows looks and uses them (even before it looks in the PATH).
A very simple fix to this problem of having missing driver file/s is to select and copy all the dll files from C:\MinGW\Bin and paste them into your C:\MyPrograms or whereever else your folder for created c++ (.cpp) files are being located.
Just search google for the dll file and download it. Then paste it into the folder in this path
C:\MinGW\libexec\gcc\mingw32\9.2.0
So I'm pretty new to Qt, and I've just inherited a project from someone else who is also new to Qt. He isn't around this week btw. We are using Visual Studio 2008, and have the latest version of Qt installed(4.6.2).
The project builds on my coworker's machine fine, and I can get the project from svn and build it directly. But under any other circumstances it refuses to build on my machine, and it doesn't give me much of an explanation why. Even if I just do a 'build clean' and then a 'build' it doesn't work. Any slight modification will make it fail.
When I try to build the entire project I get the error message:
1>Moc'ing MatrixTypeInterface.h...
1>moc: Cannot create
.\GeneratedFiles\Debug\moc_MatrixTypeInterface.cpp;.\GeneratedFiles\Debug\moc_matrixtypeinterface.cpp
1>Project : error PRJ0019: A tool
returned an error code from "Moc'ing
MatrixTypeInterface.h..."
The moc tool doesn't give any sort of error message as to why it isn't working, and I wasted most of yesterday trying to figure out why. I got the command that VS was using to call moc, and I entered in the command line myself. It didn't write anything to the screen.
Any ideas?
I finally found the answer. my coworker was back in the office today, and I used the build log off his machine to get his full moc command(about 4 lines long). Our moc commands were basically the same except at the very end. His command ended in:
-o ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp"
My command ended with:
-o ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp;.\GeneratedFiles\Debug\moc_matrixtypeinterface.cpp"
I checked the custom build step for that file, and removed the excess bit. After that the file compiled fine. I don't know how or why qt decided to add in this extra tidbit, but it did.
Thanks for your help guys. A couple of you suspected that it was a filesystem issue, and indeed a semicolon is not allowed in a windows filename. But I feel the root cause was Qt creating the wrong build string.
I'm accepting my own answer in the hope that it will help someone else.
It's most likely a filesystem error, you probably don't have a "GeneratedFiles" folder or don't have the correct permissions on it.
I have had issues where different versions of the moc and the add-in use "Generated" or "Generated Files" or "GeneratedFiles" for the folder. Check the settings on all the build steps.
Its possible that your .vcproj file is corrupted. I've had this issue before which resulted from having different versions of Qt and the Qt VS add-on ended up corrupting my .vcproj files. For a while, I had to manually fix the .vcproj file (My AdditionalDependencies="..." line was being swapped around and cut off for various header files that needed to be mocced, I was manually fixing these for every new header that needed to be mocced).
A clean reinstall of Visual Studios + Qt + Qt add-on ended up fixing this. Check your .vcproj file and see if its making sense.
Are you sure your file paths are correct and existing before moc runs? Since it appears that relative paths are provided to moc, I'd find out what moc's working directory is when it runs.
How was your .vcproj file generated? Was qmake used? Or cmake? Or was it by scratch?