Does anyone know what the "-FC" option does in gcc g++? - c++

Does anyone know what the "-FC" option does in g++?
I have it in my SConstruct script that builds the command line g++ command, I have searched google

You know, if all fails, read the manual :-).
Fdir
Add the framework directory dir to the head of the list of directories to be searched for header files. These directories are interleaved with those specified by -I options and are scanned in a left-to-right order.
[...]
Source: http://gcc.gnu.org/onlinedocs/gcc-4.4.3/gcc/Darwin-Options.html#Darwin-Options
So -FC will apparently add the framework directory "C" to the header file search path.

Related

How Can I Include Header Files by Compilation Flags? [duplicate]

Is it possible to specify extra header files to include from the command line (using GCC 4 / C++)?
Or is there any other way files can be included except with #include?
Background: I'm trying to compile a large code base on my own PC. The code is usually compiled in a cluster, with a complicated build system (SoftRelTools anybody?), which is intertwined with the operating system, such that it is virtually impossible to install it somewhere else (literally hundreds of makefiles and shell scripts, and hard coded paths to network drives). However, the actual code is fairly straightforward, and compiles fine, BUT it is missing a lot of includes (mostly a la "include <vector>" and "include <math.h>"). I'm guessing the build system takes care of this usually, but I have to go through the code and add the includes manually, which I'd rather avoid.
I found the -include option. Does this what you want?
-include file
Process file as if "#include "file"" appeared as the first line of
the primary source file. However, the
first directory searched for file is
the preprocessor's working directory
instead of the directory containing
the main source file. If not found
there, it is searched for in the
remainder of the "#include "...""
search chain as normal.
If multiple -include options are given, the files are included in the
order they appear on the command line.
From the gcc manual:
-include file
Process file as if "#include "file"" appeared as the first line of the primary source file. However, the first directory searched for file is the preprocessor's working directory instead of the directory containing the main source file. If not found there, it is searched for in the remainder of the "#include "..."" search chain as normal.
If multiple -include options are given, the files are included in the order they appear on the command line.
According to gcc documentation, the command line switch "-include file" would do the job.

Change gcc include path globally

So, I'm trying to compile Ardour, on my 64-bit Mac (OS X 10.8.5), but it can't find some header files. The header files are located in /opt/local/include, which doesn't show up in gcc's list of search paths, as returned by gcc -x c++ -v -E /dev/null.
I've read How do I add a directory to C header include path?, and tried setting C_INCLUDE_PATH=/opt/local/include, but nothing's changed - gcc still doesn't list it as an include path. (I also tried CPP_INCLUDE_PATH, just in case - no dice.) I can't (reasonably) add a command line option to specifically include that directory, since the project uses a config script. Any ideas?
Typically for C++ it should be:
CPLUS_INCLUDE_PATH=/opt/local/include
export CPLUS_INCLUDE_PATH
You can also set that in your .bash_profile for future use.

cannot open graph file gcov with gcc

I am using gcov as my code coverage tool for my c++ project with gcc (currently 4.6.3 but soon to be 4.8) on Ubuntu 12.04 and am getting the error cannot open graph file. What does this error mean? And how do I get rid of it so that I can see my code coverage?
I've seen other solutions to this problem the most popular being to use clang (gcov: cannot open graph file) instead of gcc but I can't switch compilers, I have to use gcc so that is not a workable solution for me. Plus, the documentation on gcov says that it should work with gcc.
Another solution was to fix a configuration file (http://ubuntuforums.org/showthread.php?t=1547252) but I'm not sure what configuration file this user is speaking of so if that is my problem as well I don't know how to fix it
my .gcda and .gcno files are correctly being generated in my obj directory
beyond going into my top directory where I compile my code and doing gcov *.c I'v also tried
gcov -o directory/to/obj *.c
and
gcov -o directory/to/obj *.gcda
and
gcov -o directory/to/obj *.gcno
but none of these solutions work; i still get the cannot open graph file error.
Any help or advice would be appreciated!
The above problem is due to absence of .gcda and .gcno file in the directory where your source code present .
So my suggestion is 1st copy one .gcda and .gcno file of particular .c file in your source code where your .c resides then execute gcov filename.c.
If you get coverage ,then try to soft link all your .gcda and .gcno to source code if dont want to copy from obj directory then as u stated problem ll be solved
Let me clarify few of the things that you were doing wrong.
First: you always tried to specify *.gcda, *.gcno, *.c etc after obj directory path, which is totally wrong.
What you need to do is to specify it as "-o path/to/obj/ " (path to directory)
You can even specify path to gcda file of that particular c/c++ source file and specify path to obj directory in "-o" flag to get the report for that file.
And if you use gcovr instead of gcov for your reports then you can get all the kind of reports by specifying only the root directory (directory above src & obj) with "-r -root=ROOT" flag.
Refer to this user guide for details on gcovr.

How to find "my" lib directory?

I'm developing a C++ program under Linux. I want to put some stuff (to be specific, LLVM bitcode files, but that's not important) in libraries, so I want the following directory structure:
/somewhere/bin/myBin
/somewhere/lib/myLib.bc
How do I find the lib directory? I tried to compute a relative part from argv[0], but if /somewhere is in my PATH, argv[0] will just contain myBin. Is there some way to get this path? Or do I have to set it at compile time?
How do GNU autotools deal with this? What happens exactly if I supply the --prefix option to ./configure?
Edit: The word library is a bit misleading in my case. My library consist of LLVM bitcode, so it's not an actual (shared) object file, just a file I want to open from my program. You can think of it as an image or text file.
maybe what you want is :
/usr/lib
unix directory reference: http://www.comptechdoc.org/os/linux/usersguide/linux_ugfilestruct.html
Assume your lib directory is "../lib" relative to executable
First you need to identify where myBin located, You can get it by reading /proc/self/exe
Then concat your binary file path with "../lib" will give you the lib directory.
You will have to use a compiler flag to tell the program. For example, if you have a plugin dir:
# Makefile.am
AM_CPPFLAGS = -DPLUGIN_DIR=\"${pkglibdir}\"
bin_PROGRAMS = awesome_prog
pkglib_LTLIBRARIES = someplugin.la
The list of directories to be searched is stored in the file /etc/ld.so.conf.
In Linux, the environment variable LD_LIBRARY_PATH is a colon-separated set of directories where libraries should be searched for first, before the standard set of directories; this is useful when debugging a new library or using a nonstandard library for special purposes.
LD_LIBRARY_PATH is handy for development and testing:
$ export LD_LIBRARY_PATH=/path/to/mylib.so
$ ./myprogram
[read more]
Addressing only the portion of the question "how to GNU autotools deal with this?"...
When you assign a --prefix to configure, basically two things happen: 1) it instructs the build system that everything is to be installed in ${prefix}, and 2) it looks in ${prefix}/share/config.site for any additional information about how the system is set up (it is common for that file not to exist.) It does absolutely nothing to help find libraries, but depends on the user having set up the tool chain properly. If you want to use a library in /foo/lib, you must have your toolchain set up to look there (eg, by putting /foo/lib in /etc/ld.so.conf, or by putting -L/foo/lib in LDFLAGS and "/foo/lib" in LD_LIBRARY_PATH)
The configure script relies on you to have the environment set up. It does not help you set up that environment, but does help by alerting you that you have not done so.
You could use the readlink system call on /proc/self/exe to get the path of your executable. You might then use realpath etc.

Include header files using command line option?

Is it possible to specify extra header files to include from the command line (using GCC 4 / C++)?
Or is there any other way files can be included except with #include?
Background: I'm trying to compile a large code base on my own PC. The code is usually compiled in a cluster, with a complicated build system (SoftRelTools anybody?), which is intertwined with the operating system, such that it is virtually impossible to install it somewhere else (literally hundreds of makefiles and shell scripts, and hard coded paths to network drives). However, the actual code is fairly straightforward, and compiles fine, BUT it is missing a lot of includes (mostly a la "include <vector>" and "include <math.h>"). I'm guessing the build system takes care of this usually, but I have to go through the code and add the includes manually, which I'd rather avoid.
I found the -include option. Does this what you want?
-include file
Process file as if "#include "file"" appeared as the first line of
the primary source file. However, the
first directory searched for file is
the preprocessor's working directory
instead of the directory containing
the main source file. If not found
there, it is searched for in the
remainder of the "#include "...""
search chain as normal.
If multiple -include options are given, the files are included in the
order they appear on the command line.
From the gcc manual:
-include file
Process file as if "#include "file"" appeared as the first line of the primary source file. However, the first directory searched for file is the preprocessor's working directory instead of the directory containing the main source file. If not found there, it is searched for in the remainder of the "#include "..."" search chain as normal.
If multiple -include options are given, the files are included in the order they appear on the command line.
According to gcc documentation, the command line switch "-include file" would do the job.