cross-compiling
What is a toolchain and a cross compiler? [closed]
If we define the word “host” to mean a computer on which you are compiling, and “target” as the computer on which you want to run the code, then a native compiler is one where the target and the host are the same (kind). A cross-compiler is a compiler where the target is different from … Read more
Can I skip cmake compiler tests or avoid “error: unrecognized option ‘-rdynamic'”
You can set CMAKE_<LANG>_COMPILER_WORKS to true to suppress further compiler checks for that language. set(CMAKE_C_COMPILER_WORKS 1)
Manual for cross-compiling a C++ application from Linux to Windows?
The basics are not too difficult: sudo apt-get install mingw32 cat > main.c <<EOF int main() { printf(“Hello, World!”); } EOF i586-mingw32msvc-cc main.c -o hello.exe Replace apt-get with yum, or whatever your Linux distro uses. That will generate a hello.exe for Windows. Once you get your head around that, you could use autotools, and set … Read more
When using CGO_ENABLED is must and what happens
Many things are only available as C libraries, and re-implementing that all in Go would be costly. cgo has its downsides, but it can be a good trade-off. Even the standard library uses it (net for DNS lookups, os/user for user lookups) because it doesn’t re-implement 100% of the behaviour in Go. Cross-compiling C code … Read more
CMake: specifying build toolchain
Have a look here: basically, you define a “toolchain file” that sets things like the system name, paths to compilers and so on. You then call cmake like so: cmake /path/to/src -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain/foo-bar-baz.cmake
Tool to analyze size of ELF sections and symbol
You can use nm and size to get the size of functions and ELF sections. To get the size of the functions (and objects with static storage duration): $ nm –print-size –size-sort –radix=d tst.o The second column shows the size in decimal of function and objects. To get the size of the sections: $ size … Read more
Embed resources (eg, shader code; images) into executable/library with CMake
As an alternative to the answer of sfstewman, here’s a small cmake (2.8) function to convert all files in a specific folder to C data and write them in wished output file: # Creates C resources file from files in given directory function(create_resources dir output) # Create empty output file file(WRITE ${output} “”) # Collect … Read more
How to cross compile from Windows to Linux?
It tells you it needs all tools built before you can use them. If your windows GOARCH is amd64, then you could “build” all required tools by running this small batch programs: set GOARCH=amd64 set GOOS=linux go tool dist install -v pkg/runtime go install -v -a std If that succeeds then you should be able … Read more