How to compile WindRiver/Eclipse C++ projects from the command line? - c++

I'm currently running a variant of Eclipse known as WindRiver, which is designed for embedded systems programming using C++ (specifically, I'm part of my high school's FIRST Robotics team).
I'm able to successfully compile and build the project from within Eclipse (Project > Build Project) but I'm looking for ways to automate this process by compiling by using the command line.
The project already contains a makefile and everything, so ideally I want to be able to just run that without making any manual changes. I pastebin'd the makefile in case its relevant.
Does anybody know where I can find more information on compiling C++ programs from the command line for either Eclipse or WindRiver or on running makefiles on Windows? I tried looking at "How to run a makefile in Windows?" but following the first answer didn't work (it gave a syntax error for the makefile).
I'm currently using a Windows 8 laptop. As best as I can tell, the current varient of WindRiver I'm using is based on Eclipse version 3.3.1.

You will need a make utility, I believe your WindRiver / Eclipse setup would come with "gnumake" (probably called either make or gmake). You'd nee dto set up the command line path to lead to the compiler and the make executable. Unfortunately, this is not a great answer, as I can't give you exact links to the make and compiler locations (it would of course also depend on where you installed things). I just thought I'd lead you somewhat on the right path, since the question has been up for a little while and no one jumped at it.

Thanks to Mat Petersson's answer, I was able to identify everything I needed and create a batch file that could compile the file for me:
#echo off
setlocal
set PATH=%PATH%;C:\WindRiver\gnu\3.4.4-vxworks-6.3\x86-win32\bin;C:\WindRiver\utilities-1.0\x86-win32\bin;C:\WindRiver\setup\x86-win32\bin
set WIND_BASE=C:\WindRiver\vxworks-6.3
cd My_Project\PPC603gnu
make --no-print-directory BUILD_SPEC=PPC603gnu DEBUG_MODE=1 TRACE=1

Related

ArUco program from scratch

I'm using the ArUco library with OpenCV (more information here) but I can't find a way to build and run a program from scratch.
Once I installed the library I have access to different examples but if I want for instance to create a new file and add the library headers inside it, how can I compile and run it ? (with a command line or IDE, anything is fine)
Thank you
I sent and email to the library's author and he added clear instructions at the end of the project webpage :)
It seems you need to learn how to use your IDE's, compilation tools and general compilation basic stuff. This is not a question related to Aruco, or mostly any other tags you have set.
Try to lean CMake first, 'cause Aruco compilation is based on CMake: http://www.cmake.org/
You can start by just editing the aruco_simple example.
For a IDE that works right away with CMake you can try either Qt Creator >3.1 or KDevelop. Both free.

Integrate Octave with C++ in QtCreator IDE

I am trying to do some DSP operations in C++ using Octave...I have been trying to integrate Octave with QtCreator 5.1 (MinGW compiler) with no success...I have done the following steps...
Downloaded Octave3.4.3_gcc4.5.2-install.exe and intsalled in C drive. I have added the address of the bin folder of octave to the environmental variable PATH
Set the INCLUDEPATH and LIBS according to the location of the header files and the libraries of the Octave directory.
This is the sample program I am trying to run .
The code builds successfully. However while running it hangs up. Debugging yeilds the following message.
I tried to create an executable using the command prompt of octave using the command mkoctfile --link-stand-alone octavetest.cpp -o octavetest. The executable created also hangs up with an error message.
If anyone can point out where exactly I am going wrong in the integrating process it would be realy helpful. Is there any other simple way to set up the environment to call Octave APIs from C++? I have almost checked on the internet forums including stack overflow with no luck...
Your gcc/libstdc++ version will likely be incompatible with the one octave got compiled with.
This compiler is as close as i got to the one used to build the current octave-binaries.
If you extract both archives and add their bin directories to your path variable, you should be able to build octave programs. Your linked sample builds for me.
You can also add the compiler in QtCreator. (Tools⇒Options⇒Build&Run)
I have done exactly the same thing on Windows. In my experience, you need to build Octave with exactly the same compiler that you're building your executable with. That's all there's to it. This really means you have to build Octave from sources. I have wasted a lot of time avoiding to build Octave, and in the end could never be sure that it'll be stable or not. Octave will build with VS 2012 with very minor tweaks.
Building Octave is really the only practical way to go, I think. The amount of time you spend setting up an Octave build will insignificant in the long run.

What is MakeFile in Eclipse?

What is MakeFile in Eclipse? From the documentation:
A makefile is a text file that is referenced by the make command that
describes the building of targets, and contains information such as
source-level dependencies and build-order dependencies. The CDT can
generate a makefile for you, such projects are called Managed Make
projects. Some projects, known as Standard Make projects, allow you to
define your own makefile.
But the explanation does not help me understand what a MakeFile is. I am moving from VisualStudio/C# to Eclipse/C++. Is MakeFile analogous to Visual Studio's Metadata? When do I need to write a MakeFile, and why do I need it besides the C++ code?
[EDIT]
I used to develop on Windows with VS and C#. And now trying Eclipse/C++ on a Mac. I have never build anyone on Linux. So the answer I have read so far does not help explain anything at all.
A makefile in the simplest terms is a file that builds a program. These are normally used from the command line. If you have ever built something on linux you may have run ./configure ; make ; make install. You are using a makefile there.
More info...
https://en.wikipedia.org/wiki/Make_(software)
In simple terms: Make helps you create cross-platform configuration settings in one file, and it will work on surprisingly many platforms, including Windows or Mac OS-es.
Mentioning Windows, you should have Make installed on the computer you're installing on (on Windows, Cygwin and MinGW include Make). It's required only if the user will actually build the code from the source.
But of course, you should include Make code for each different platform (e.g. one for Unix-like, one for Windows, etc.)

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.

Is there an equivalent of Make on Windows? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I develop on Windows, and I'd like to use beanstalkd. It's only available as a tarball, and I was just wondering if there is some way to easily build it like you can in Linux? I found some ports of gnu make for Windows, but they don't seem to be working. Are the source distributions somehow specific to Linux?
When I try to use mingw32-make it says "Nothing to be done for file". TBH I wasn't sure what to run it on, so I tried the tarball, the directory, and Makefile.in and Makefile.am. They all say the same thing.
Make is available in cygwin, which you can install make via the installer.
The package is called "make", which is under "Devel" category.
I found some ports of gnu make for
Windows, but they don't seem to be
working.
Here are a few ports of GNU tools to Windows:
GnuWin32 - http://gnuwin32.sourceforge.net/summary.html
Gnu Tools for NT - http://www.devhood.com/Tools/tool_details.aspx?tool_id=3
GNU Utilities for Win32 - http://unxutils.sourceforge.net/
I am pretty sure I have used some of the utilities from the unxutils port without problems.
I would also look into using msys with mingw (it also can be found at http://mingw.org) I could try to explain it but I think the description from their page works better
MSYS: A Minimal SYStem providing a POSIX compatible Bourne shell environment, with a small collection of UNIX command line tools. Primarily developed as a means to execute the configure scripts and Makefiles used to build Open Source software, but also useful as a general purpose command line interface to replace Windows cmd.exe.
One bonus of using msys over cygwin is it builds native windows applications rather than having to rely on the cygwin compatibility layer
Most unix source packages require you to run "configure", which reads some info about your system and builds the Makefile - although in the early days of X11, some packages used "xmkmf" to build Makefiles out of IMakefiles. Only after thats done can you run "make" and possibly "make install". From the sound of it, you don't have a Makefile, only the Makefile.in (which is input to configure).
Cygwin is nice, as the previous answer indicated, but it includes a lot more than just make.
I used to use NMake on Windows to build Perl modules. Check it out:
http://johnbokma.com/perl/make-for-windows.html
That's useful for Perl. Looks like there's a general GNU port, too:
http://gnuwin32.sourceforge.net/packages/make.htm
Cygwin and mingw come to mind.
MSVC includes nmake which kind of works on regular makefiles with some tweaking.
The make utility expects to use a file named Makefile. If you just type make, it will find that file automatically. If the makefile has some other name, use the -f option. If you just give the file name without -f, then make will interpret it as the target that it should figure out how to make.
A lot of tools that only come as source assume that you'll use Visual C++ to build on Windows, even if they assume you'll use G++ everywhere else. Look for a Visual C++ makefile; it's usually named Makefile.mak. Then run nmake.
But if you only have files named Makefile.in and Makefile.am, then you don't yet have a makable environment. Makefile.in is one of the inputs to the configure script, which will construct the real makefile and maybe a header or two that are specific to your environment, based on tests that configure runs.
In the end, the package you've downloaded might not really be compilable on Windows. Even under Cygwin, you can expect to have to make a few changes to the source code if it hasn't been written with Windows in mind.
Makefile.in will contain the basics of the final makefile. Back before I knew what I was supposed to do, I simply renamed Makefile.in to Makefile and got pretty far. You can try using that file as a starting point for constructing a real Windows makefile, for whichever compiler target you choose. It will take patience; just keep following the compiler messages until you don't see any more. (And then comes the linker. Hope you don't need too many other libraries!)
Concerning the alternatives, check out this link. As far as your problem with make, you'll have to be a little more specific about the non-working part. What doesn't work, how does it manifest, what error it gives and such.
Let someone else do the hard work. Here's a precompiled beanstalkd 1.4.6 exe.
Decompress the tarball, cd into its topmost directory and type 'make'. Make will pick up the Makefile automatically.