I am trying to compile my .cpp with -fno-leading-underscore option but it raises an error saying:
clang: error: unknown argument: '-fno-leading-underscore'
g++ -m32 -fno-use-cxa-atexit -nostdlib -fno-builtin -fno-rtti -fno-exceptions -fno-leading-underscore -o kernel.o -c kernel.cpp
How can I fix this I am new to Mac it used to work on Linux Mint
In your terminal, type g++ and press enter. You will probably get:
$ clang: No input files
As you can see its still clang underneath.
To fix this, first cd into /usr/local/bin and type ls. You will see the binaries inside:
g++-9
...
Next, create a symlink to it so that you can invoke g++ directly
ln -s g++-9 g++
If it still doesn't work for some reason, you can explicitly write g++-9 or whatever version you have. You can even give the full path /usr/local/bin/g++-9
Related
So I just reinstall gcc using home brew, when I compile a programme and try to use libstdc++... I get a error:
dhcp-18-189-47-44:openmp_code myname$ g++-4.8 -fopenmp tmp2.cpp -stdlib=libstdc++
g++-4.8: error: unrecognized command line option '-stdlib=libstdc++'
Someone has idea what is happening ? Thank you.
As the error message clearly says, g++ does not support -stdlib as an option. You can simply remove that option from the command line.
g++-4.8 -fopenmp tmp2.cpp
should be all you need.
I am working on a project where I need to generate just the bitcode using clang, run some optimization passes using opt and then create an executable and measure its hardware counters.
I am able to link through clang directly using:
clang -g -O0 -w -I/opt/apps/papi/5.3.0/include -Wl,-rpath,$PAPI_LIB -L$PAPI_LIB \
-lpapi /scratch/02681/user/papi_helper.c prog.c -o a.out
However now I want to link it after using the front end of clang and applying optimization passes using opt.
I am trying the following way:
clang -g -O0 -w -c -emit-llvm -I/opt/apps/papi/5.3.0/include -Wl,-rpath,$PAPI_LIB -L$PAPI_LIB \
-lpapi /scratch/02681/user/papi_helper.c prog.c -o prog.o
llvm-link prog.o papi_helper.o -o prog-link.o
// run optimization passes
opt -licm prog-link.o -o prog-opt.o
llc -filetype=obj prog-opt.o -o prog-exec.o
clang prog-exec.o
After going through the above process I get the following error:
undefined reference to `PAPI_event_code_to_name'
It's not able to resolve papi functions. Thanks in advance for any help.
Clearly, you need to add -lpapi to the last clang invocation. How else the linker would know about libpapi?
I've taken the great advice from this answer, checked the file list for libbotan1.10-dev and found /usr/lib/libbotan-1.10.a, so I used the linker flag -lbotan-1.10.
I've successfully been able to code and compile websocket++, json-spirit, connector/c++, and boost::lockfree::spsc_queue.
I'm now trying to use botan's passhash9 to hash passwords.
When I try to compile with
g++ -Ofast -march=native -o btServer broadcast_server_tls.cpp
-I ~/websocketpp-master/ -std=c++0x -D_WEBSOCKETPP_CPP11_STL_
-D_WEBSOCKETPP_NO_CPP11_REGEX_ -lboost_regex -lboost_system
-pthread -L/usr/lib -lssl -lcrypto -ljson_spirit -lmysqlcppconn -lbotan-1.10
g++ gives an error on the #include <botan/botan.h> line, saying "broadcast_server_tls.cpp:12:25: fatal error: botan/botan.h: No such file or directory".
To install on Ubuntu 12.10, I did apt-get install libbotan1.10-dev.
How can I correct this?
You should compile as:
g++ "whatever_source_file" "whatever flags you are already using" -I/usr/include/botan-1.10/
I have a warning involving /usr/local/lib/gcc/x86_64-apple-darwin10.8.0/4.6.4/libgcc.a. I was trying to compile a C++ project using a Makefile, which shows the following:
executeit: bplustree.o nonleafnode.o leafnode.o
g++ -o executeit bplustree.o nonleafnode.o leafnode.o
bplustree.o: bplustree.cpp
g++ -g -c bplustree.cpp
nonleafnode.o: nonleafnode.h nonleafnode.cpp
g++ -g -c nonleafnode.h nonleafnode.cpp
leafnode.o: leafnode.h leafnode.cpp
g++ -g -c leafnode.h leafnode.cpp
clean:
rm executeit bplustree.o nonleafnode.o leafnode.o
When I invoke "make", I get the following output in Terminal:
g++ -g -c bplustree.cpp
g++ -g -c nonleafnode.h nonleafnode.cpp
g++ -g -c leafnode.h leafnode.cpp
g++ -o executeit bplustree.o nonleafnode.o leafnode.o
ld: warning: in /usr/local/lib/gcc/x86_64-apple-darwin10.8.0/4.6.4/libgcc.a, file was built for unsupported file format which is not the architecture being linked (x86_64)
As you can see, I have gcc version 4.6.4. I am not sure if this warning is a threat to the project working in any way, but I would like to know what this warning means and if it is a threat. It would be nice if I can do something to remove it, too. Thank you.
I have Mac OS X Version 10.6.8. The file /usr/local/lib/gcc/x86_64-apple-darwin10.8.0/4.6.4/libgcc.a has "10.8.0", and this version of gcc I installed must have screwed me over. I don't know if I can remove this warning by installing OS X 10.8.0, but I will consider this question answered for now. Thank you.
I recently uninstalled macports to replace it with homebrew. However, since then, I get a weird warning when I compile some C++ code
ld: warning: directory not found for option '-L/opt/local/lib'
That is the old directory path of macport that has been deleted. However that option has never been specified. I call the following lines
clang++ -c -W -std=c++11 -stdlib=libc++ src/main.cpp -o obj/main.o
clang++ -stdlib=libc++ obj/main.o -o bin/myprog-debug
I checked the variable LD_LIBRARY_PATH but it is empty. So, where does that library path come from?