Downloading JUST g++ binary - g++

This question may seem stupid to you guys, but I am in a situation where I have no access to command line, and I need a version of g++ on my computer so I can compile my c++ code.
I looked on the GNU repository, and I have NO idea how to build and also install the environment.
Where can I simply just download the 'g++' file, without going through all these trouble?
Thanks in advance

Where can I simply just download the 'g++' file, without going through all these trouble?
Downloading the g++ file will not do you any good: the GNU C++ compiler distribution consists of several hundreds of files. The g++ is just the compiler front end, you'll also need cc1plus (the actual compiler), header files and libraries.

Related

cmake: How to debug bad flags

I am currently having a bear of a time trying to compile a moderate sized library with a brand new toolchain, Assimp on Xcode6 with the new iOS 8.0 SDK.
Bundled with the project are various scripts and Xcode projects that have configurations for building on iOS, but unfortunately none of them work out of the box.
So far the farthest I have gotten is by using a build script which uses the cmake "Unix Makefiles" method to assemble static libs. Other methods would include using cmake to generate Xcode projects to use to build. I tried that also to no avail, and neither did the Xcodeproject that comes with the project in the repository (which I later learned was marked deprecated in one of the readme files).
Okay, so with this "Unix Makefiles" cmake script I have been able to generate some of the static libs (after manually forcing static lib generation inside the main CMakeLists.txt), but when it went on to build for i386 and x86_64 architectures for iPhoneSimulator it kept pulling in the headers for iOS which caused a torrent of compiler errors.
Luckily I followed a hunch and found assimp/code/CMakeFiles/assimp.dir/flags.make which is one of the cmake-generated files, and lo and behold, the entire cflags was in here, and once I removed the rogue header include path, the make call finally succeeds and I have my iPhoneSimulator static lib!
Okay so the question that I have is basically where do I get started when debugging these frustrating cmake problems. My relationship with cmake has always been a strained one because none of cmake's complexity and design principles ever made sense to me, and very infrequent are the times when cmake builds work for me out of the box... it is always something that almost works but then I have to spend hours debugging with make VERBOSE=1 and then haphazardly poking at generated files, which are of course all marked with warnings to not edit them as they are generated files.
I realize that some of the variables here are perhaps relevant to my troubles. But it isn't clear to me how I can debug these variables. Where do I go to print out these variables so that I can find which variable contains erroneous values? For example, in this most recent situation I had a -I flag that was cropping up in the wrong place. Luckily I was able to find a file that contained it using various large-hammer methods that involve grep but I am not close to actually fixing the build configuration to make the process any less painful in the future.
For complex CMakeLists.txt files I have found the variable_watch command can sometimes be useful (documentation here). It doesn't make it easy, but gives you another level of information.

How to add header file path in CMake file

I am new to OpenCL. I have written a vector addition code in OpenCL with help from Internet. I have included one header file i.e. CL/cl.h using #include.
I am using NVIDIA graphic card and the OpenCL implementation is NVIDIA_GPU_Computing_SDK. My OpenCL header files are residing at this path /opt/NVIDIA_GPU_Computing_SDK/OpenCL/common/inc. I can run OpenCL programs through linux terminal by adding this path when compiling my code. But now I want to write CMake file for this code. CMake files are working fine for C programs, but not OpenCL programs because of this Path problem. In terminal, I used to enter $cmake ., after this $make, it will search for a Makefile which is created by cmake, now my error is after entering command make
fatal error: CL/cl.h: No such file or directory!
Now tell me how can I include this header file into CMake file?
You will need to put these lines into CMakeLists.txt:
include_directories(/opt/NVIDIA_GPU_Computing_SDK/OpenCL/common/inc)
link_directories(/opt/NVIDIA_GPU_Computing_SDK/OpenCL/common/<lib or something similar>)
add_executable(yourexe src1.c ...)
target_link_libraries(yourexe OpenCL)
But beware that this is not portable, because OpenCL SDK can be somewhere else on another machine. The proper way to do this is to use FindOpenCL.cmake module.
Maybe you can use a CMake "find" script like:
http://gitorious.org/findopencl/findopencl/blobs/master/FindOpenCL.cmake
http://code.google.com/p/opencl-book-samples/source/browse/trunk/cmake/FindOpenCL.cmake?r=14
CMake file example from OpenCL Programming Guide Book: http://code.google.com/p/opencl-book-samples/source/browse/trunk/CMakeLists.txt?r=14
I was looking for FindOpenCL.cmake macro which would work well on Windows, OSX and Linux... I couldn't find any which did work well on every platform, so I wrote new one which I use in couple of projects (webcl-validator and opencl-testsuite).
https://github.com/elhigu/cmake-findopencl
Especially Windows support is improved in this one.
In Windows it checks if 64bit or 32bit lib should be used and it also tries to find libraries from according to environment variables set by Nvidia, Intel and AMD OpenCL SDKs.
It also tries to find .lib in Cygwin, which didn't work with other scripts I tried.

How do you use libtool to create .a files (static libraries) on Mac OS?

When it comes to using the terminal to build libraries manually and such I unfortunately do not have much experience and I'm stuck a bit here.
I've downloaded a library for objective-c which came with makefiles and such.
I can see that the folder also contains an executable file called "libtool", I did some searching and I suppose this is the program I have to use to build the neccessary .a files? Unfortunately I couldn't really find any useful article for this that seemed to work.
The folder for the library contains some .sh files, .pc files and also some .la files, but I'm a bit unsure of which ones I have to use as input to the libtool program to compile them into a .a file.
So my question is what files do you have to input into libtool to compile them into the necessary .a file? And what commands do you use exactly to accomplish this?
Thank you all for your time :)
First a little introduction to static libraries:
Static libraries in Unix environments (like Mac OSX, and Linux too) are actually just an archive of object files created by the ar command line program.
That is what the .a extension stands for: Archive.
To create a static library with some object files you can use the command like this:
ar crv libmy_library.a objectfile1.o objectfile2.o
As for your actual question, libtool should be called automatically from the makefile, creating the library, which is the file ending in .la. However, this is not the real library, the real library is in a hidden directory. You can find it by doing e.g.
find . -name '*.a'
But like I said, the makefile should already take care of everything, including installing the correct library in the correct place when you do e.g. make install.
For information about libtool, see this site.

vtune with mingw

I am trying to use vtune with my application compiled with mingw in Windows.
When I try to see souce code information, vtune says the is not line information in the resulting executable. I am compiling with -g option so I dont know where is the problem. So the questions are:
Is it possible to profile with a program compiled with mingw in windows? It looks like all is ready for MS-VC, but not for mingw.
If so, is it needed to change the object format (coff, xcoff, DWARF, ....)?
maybe if someone post an example it would be valuable.
Solved, compiled with
-gstabs -g3

Objective-C syntax checker

Is there an Objective-C syntax checker?
I have tried gcc -fsyntax-only but it is not really 'syntax only'. It still produces errors if run on an individual implementation file which has references to external frameworks.
I am looking for something that can perform a syntax check on individual header or implementation files without attempting to link or produce object files.
Can gcc do this with additional flags I am unaware of, or is there another tool up to this task?
I want to do this from the command-line. Can xcodebuild do this for an individual file? Running xcodebuild for the entire project to check the syntax of one file is a bit much.
There's no way for it to check the syntax without it knowing about the header files for the frameworks you are using. You need to use the -framework flag to include the relevant header files.
You could try using clang -fsyntax-only instead, especially if you're using 10.6/Xcode 3.2. Clang/LLVM has much better separation between the parser and the other parts of the compiler chain. You can find clang in /Developer/usr/bin.
So after trawling through the gcc man page I discovered the -F flag which lets you add a framework directory to the list of directories gcc searches for header files.
This solves my issue.
Use it like this: gcc -fsyntax-only -ObjC -F/Path/To/A/Framework -F/Path/To/Another/Framework File.m
You can compile a single file in Xcode[1] using Build->Compile (cmd-K) which is effectively a syntax check (there's no linking step).
[1] I assume you're using Xcode, as there's little point in using Objective-C without OS X (really the Cocoa frameworks).