Make Eclipse generate C++ executable file - c++

Using latest MinGW and C++ Eclipse.
If I create an "Executable Hello World" project, build it and run it, everything works as expected.
If I create an "Executable Empty Project", then create a main.cpp file, build and run, I get the error message "Launch failed. Binary not found."
How can I make empty project generate binary files? I looked everywhere in the project properties but I must have missed it.

For me the solution was this:
select your project and goto "project"-menu/properties (on mac).
c/c++ Build/Settings.
Binary parsers. now tick the one that suits your system (elf for linux, mach 64 for mac, pe for windows etc). the default is always elf and it reverts to it after every project, at least for me.

On Eclipse Kepler (c++) with standard settings I today discovered that the error parser that creates the output in the "Problem" tab failed
In the console there was an compile error from gcc, but it didn't show in the Problem tab, which is the one I look in the most. It was a type conversion error, very typical and nothing exotic, definitely something that should be included as an error.
Hope it helps someone.

Related

Nothing compiles after cleanup

I'm writing a C++ wxWidgets calculator application. I recently started getting some random IntelliSense errors that did not however stop compilation. I followed an advice online and performed Clean Solution after deleting the .suo file in my project directory. Now I'm getting 92 errors that do however interrupt compilation, and I have no idea what to do.
"Cannot open error code ".." of source file
Cannot open inclusion file: ".." no setup.h such file or directory
And lots of other erros of these kinds, along with random syntax errors.
I think that the problem might be that VS isn't finding wx/wx.h for some reason.
My setup (don't know if it has anything to do with the errors)
To start programming with wxWidgets, I followed a YT tutorial. I have my wxWidgets files in my D: disk. I have a WXWIN system variable pointing to that directory. In Project properties > C/C++ > General > Additional include directories I have $(WXWIN)\include; $(WXWIN)\include\msvc. Then, in Linker > General > Additional library directories I have $(WXWIN)\lib\vc_lib.
After Clean Solution these options were reset to default (along with _CRT_SECURE_NO_WARNINGS preprocessor) and I had to re-enter them. Now I'm getting all these errors and I don't know what to do.
It seems you simply didn't build wxWidgets itself in x64 release configuration that you use. You must do it before using it.
I also strongly recommend following the official installation instructions rather than tutorials that may be out of date.
Apparently I accidentally changed the combo box left of the "Local windows debugger" button from x86 to x64. I switched it back to x86 (even if I don't know what that means) and everything is back as it is.

unit-testing dll relying on 64-bit itk-framework

I am trying to set up a "Native Unit Test Project" (Visual C++) that is testing a DLL-project which is based on the ITK framework. I will probably want to mock ITK implementations, but for a start I just want to make a function call that does depend on the actual library. Everything is running on x64, only I don't seem to be able to build the unit test project in x64, the configuration manager only allows for win32. I have set test>test settings>default processor architecture>x64, but that doesn't seem to help. When compiling I get:
...itk-4.8.1\x64\debug\include\itk-4.8\itkmathdetail.h(286): error C3861: '_mm_cvtsd_si64': identifier not found
When I look at project>properties>configuration properties>VC++ directories it says "...x86" all over the place, while in the project I'm trying to test it says "....x64".
How can I get this to work, please? Or am I on mission impossible???
Update:
I now managed to run the project with x64 settings. In this case I have the trouble that the unittest framework only runs on win32, hence:
error C1083: Cannot open include file: 'CppUnitTest.h': No such file or directory
So...during compile-time I can choose whether my library doesn't compile (win32-mode) or the unit-test framework doesn't compile (x64-mode). A reminder: Compiling in win32-mode and setting test to "default processor architecture = x64" does not do the trick either, still compile errors described earlier. On that front, I have tried using a runsettings file, which made no difference.
Ok. I found out where things went wrong. 1st of all everything has to be compiled in x64, also the unit test project. And if you make sure you follow these steps on how to set up a x64 project
https://msdn.microsoft.com/en-us/library/9yb4317s.aspx
then you end up without trouble. However you need to make sure you copy win32 settings and DON'T tick "Create new solution platforms".

How to set up wxWidgets 3.1.0 with Visual Studio 2015

I am somewhat of a beginner when it comes to open source libraries. I have tried to compile from source and use the pre-built binaries, but in both cases I get a ton of errors when I try to run the simple 'Hello World' program on the tutorial section of the wxWidgets website. After playing around for quite some time, the closest I have got to compiling is by building the libraries from source, but I still have 2 errors remaining:
"_w64 can only be specified on int, long, and pointer types" file: defs.h
"cannot open file 'wxbase31ud.lib" - LINK
It seems strange to me that the header file provided by wx would have an error such as that one, so I imagine both errors are because of something I am doing. I am hoping that someone here can do one of the following for me:
Help me solve these errors
Provide instructions for building libraries from source and subsequently linking my program to the correct directories
Some additional info: I am working on x64 Windows 7, my target will also be x64 exclusively. I do not have admin privileges, so no editing the system PATH for me.
Thanks for your help!
The simplest way to start working with the library is this:
Grab the sources.
Unpack the sources.
Open VS IDE.
Open \build\msw\wx-vc14.sln (adjust as necessary.)
Go to "Build->Batch Build...", click "Select All", "Build".
Go drink some coffee or watch TV.
After the build finishes, open wxWidgets/samples/minimal/minimal_vc9.sln.
Let MSVC convert the solution to become an appropriate format.
Build and run the sample.
If you will acquire any issue during those steps, let us know.
The library build in step 5 should build without any issues and then all you will need is to build the minimal sample.
The next step is to copy the samples\minimal folder somewhere and start writing the code. All you will need to do is to change the Include and Lib search path.
[EDIT]
If you can build the 32-bit libraries (which are default in the provided solutions) all you will need is to convert them to be 64-bit and rebuild.
There is no changes to the $PATH or any environmental variable involved. Moreover you shouldn't build anything with the admin priviledges.
Also as Thomas pointed out you library build has to match whatever sample you are trying to build.
[/EDIT]

How can I debug a C++ executable compiled externally (with debug flags set) from inside Eclipse?

I have a large C++ project, different parts of which are compiled in different ways (bjam/make). I was having trouble getting it to build from within Eclipse. Could I build the code externally (with g++ -g), and then just run the debugger from within Eclipse?
I figured it out. Should've looked earlier at this: http://wiki.eclipse.org/CDT/User/FAQ#Debugging_C.2FC.2B.2B_Projects
I first added my project to eclipse. Then I followed the instructions above to set up a debug configuration. And somewhat surprisingly eclipse is able to figure out that the binary I want to run refers to the project that I have open, and so I can actually set breakpoints, step through the code while eclipse shows me which line in which file I'm at, etc. So its exactly as if I built the project from within eclipse. Its impressive :)

Import existing C++ project into Xcode IDE

I am trying to open an existing C++ open-source library in Xcode to publish it with my own modification/additions. The library is Tesseract-OCR, which does not include a .xcodeproj file.
Since Xcode can function as an IDE, is it possible to open a bunch of files as a single project in Xcode? Is there an easy way to produce an Xcode project?
There are several ways you could do it, depending on the level of IDE integration you want. There's no direct way of importing a Makefile-based project into Xcode. You can create a project that builds via the Makefile, but you wouldn't get many of the benefits of using an IDE, since the editor features such as word completion rely on Xcode being able to parse the files in the project. You will be able to use the debugger though. To do this, create a new project and add a custom target with a script build phase that just calls down to Makefile.
If however the project you're building compiles very easily, ie without requiring a lot of macros to be set up, include paths, etc, then it may be simple to just create an empty project and merely add all source files to it. I've used this method extensively for building boost libraries. If this is a configure && make type project then you will probably have to run the configure step first, and ensure any top level config.h files are included in the project.
If the project has a complex makefile then it is likely to be an involved task to create a useful Xcode project
I realise you asked explicitly for Xcode, but in case you were actually trying to solve the problem of "I have existing C++ code which builds and runs fine from the command line, and I'd like to code and debug it in an IDE, what should I do?" my firm recommendation would be to avoid Xcode and go for Eclipse.
The reason is that as far as I can tell, Xcode has no way of ingesting the command line build environment and effectively requires you to recreate the make process inside Xcode from scratch. Fine for tiny projects, but anything with more than a few source files and it quickly becomes painful. Whereas in Eclipse everything is built around Makefiles. So in my case I got to the "step through code with working code completion" in Eclipse a lot quicker vs. never in Xcode. This of course could be because I'm an Xcode noob, but my 2c.
To create an Xcode project from an existing cmake project, you can run cmake -G Xcode. It produces some folders and files apart from the project file, so it might be better to create a folder for it first. For example:
mkdir -p build/xcode
cd build/xcode
cmake -G Xcode ../..
Xcode is a useable IDE for library creation.
Of course a good first step is to see if the one source code will build on its own with configure scripts that are included.
If not, it becomes a question of how many libraries you need to link in.
There are resources online (or at least there used to be) for using Xcode (or perhaps it's forerunner Product builder) for porting Unix projects to Mac.
Good tutorial at: http://www.macresearch.org/tutorial-introducing-xcode-30-organizer
Another good reference is Darwin Ports.
As for doing this on your own. You can build c++ based libraries in XCode. People do that every day. You can even use one of the Xcode templates to get you started.
However, library dev requires more experience with Xcode then say a simple Cocoa "Hello World" app.
The remaining questions will be assuring that the source code's dependencies are already built into the Mac's SDK. (Don't hold your breath for linking to MFC)
It's a general question... So it's a general answer.
In Xcode8,there is "Xcode->file->add files to...",then choose your files.If you want to add several files at a time,press "Cmd" when you are choosing.