Using Xcode to compile -fvisibility=hidden - xcode

Anyone knows how to use Xcode to compile with -fvisibility=hidden
I am new to Xcode, Some screenshot would be better.

go to your project's build settings in Xcode, use the search field to look for "Other C Flags" and then enter in "-fvisibility=hidden" like this:
More info can be seen in this very related question.

Related

using stoi problems(c++11) [duplicate]

I'm writing some code that requires to have C++11 support for my Code::Blocks 12.11. I am using default GNU GCC Compiler came with MingW. Is there any way I can do this?
Go to Toolbar -> Settings -> Compiler
In the Selected compiler drop-down menu, make sure GNU GCC Compiler is selected
Below that, select the compiler settings tab and then the compiler flags tab underneath
In the list below, make sure the box for "Have g++ follow the C++11 ISO C++ language standard [-std=c++11]" is checked
Click OK to save
The answer with screenshots (put the checkbox as in the second pic, then press OK):
A simple way is to write:
-std=c++11
in the Other Options section of the compiler flags. You could do this on a per-project basis (Project -> Build Options), and/or set it as a default option in the Settings -> Compilers part.
Some projects may require -std=gnu++11 which is like C++11 but has some GNU extensions enabled.
If using g++ 4.9, you can use -std=c++14 or -std=gnu++14.
Use g++ -std=c++11 -o <output_file_name> <file_to_be_compiled>

Specify to Xcode which binaries to use for compilation

Is there a way to specify in Xcode which binaries to use for compilation? I have recently cross-compiled clang, ld, libtool, etc, and I want to test them.
I am fully aware that I could just do something like:
/Path/To/My/Tools/clang -c file.c
/Path/To/My/Tools/ld file.o -o executable
# or
/Path/To/My/Tools/libtool -static -arch_only x86_64 -o myLib.a *.o
# and so on...
However I am looking for a way to integrate this nicely into Xcode. As my tools should (technically - this is what I want to test) be equivalent to the built-in tools, I don't need to change any of Xcode's default compilation args, etc. I just need to tell it to find the binaries some place other than /usr/bin or somewhere in the ${SDKROOT} or *.xctoochain directories. Is this possible?
There is a project setting for this. In your Xcode project, open the "Project Navigator" and click on the icon for your project. It should show the project settings. In the "Project" section of the project settings, click on the "Build Settings" tab. Type "compiler" into the search field, and it should show you the "Build Options" setting for "Compiler for C/C++/Objective-C". It defaults to Apple LLVM 5.0, but you can change it. Click on "Default (Apple LLVM 5.0)" and select "Other…" It will pop up a text field where you can enter the path to your own tools. It should look like this:

Undefined symbols for architecture x86_64 error in Xcode 5 in OS X Mavericks

Somewhat a similar problem with this issue but this only happened after I upgraded to Mavericks and Xcode 5.0.2.
I'm able to compile and run with
g++ `pkg-config --cflags --libs opencv` prog.cpp
but got linker errors when trying to run with Xcode like those found in the linked question.
I've tried many possible configurations like changing 'Library Search Path' to '/usr/local/lib' and adding directories to 'Header Search Paths' like '/usr/local/lib', '/usr/local/include' and '/opt/local/include'. I've also tried to all possible options in 'C++ Standard Library' like 'libstdc++', 'libc++' and 'Compiler Default'. I'm really running out of ideas as to where the problem may lie.
For the cpp file, I've simply included <opencv2/opencv.hpp>.
I was also suffering from this for the past couple of days. From the same post you were referencing:
I've set the Build Settings -> c++ standard library to Compiler
Default. The errors disappeared.
This worked for me.

How can I add C++11 support to Code::Blocks compiler?

I'm writing some code that requires to have C++11 support for my Code::Blocks 12.11. I am using default GNU GCC Compiler came with MingW. Is there any way I can do this?
Go to Toolbar -> Settings -> Compiler
In the Selected compiler drop-down menu, make sure GNU GCC Compiler is selected
Below that, select the compiler settings tab and then the compiler flags tab underneath
In the list below, make sure the box for "Have g++ follow the C++11 ISO C++ language standard [-std=c++11]" is checked
Click OK to save
The answer with screenshots (put the checkbox as in the second pic, then press OK):
A simple way is to write:
-std=c++11
in the Other Options section of the compiler flags. You could do this on a per-project basis (Project -> Build Options), and/or set it as a default option in the Settings -> Compilers part.
Some projects may require -std=gnu++11 which is like C++11 but has some GNU extensions enabled.
If using g++ 4.9, you can use -std=c++14 or -std=gnu++14.
Use g++ -std=c++11 -o <output_file_name> <file_to_be_compiled>

How does one compile and link NASM code with Xcode?

Note that this question pertains specifically to Xcode 4, though additional information about other versions of Xcode are welcome.
Part 4 of this tutorial at Cocoa Factory recommends generating object code with
nasm-2.09.10 -f macho64 hello64.asm
(after putting nasm-2.09.10 in /usr/bin)
and linking it with
gcc -m64 -mmacosx-version-min=10.6 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -o hello64 hello64.o
and that's just fine, but I don't want to do my compiling/linking at the command line, I'd like to just click Build and Run and have it all done for me. I imagine there must be some way to get Xcode to use those commands to compile my source when I Build, but how?

Resources