User forums > Using Code::Blocks

Cross Compile for linux in windows using cygwin

(1/1)

adityagameprogrammer:
with the full cygwin install i.e the cross compile tools. To get the executable file for linux it is a simple matter of invoking the cross compiler in cygwin like


--- Code: ---gcc-linux -o output input.c
--- End code ---

How can we set this up in codeblocks environment?

to use the cygwin gcc we simply have to locate to the exact version of gcc which we want to use and set it in toolchain executables
like for
--- Code: ---cygwin c++ compiler C:\cygwin\bin\g++-4.exe
--- End code ---
.

But the cross compile tools have the linux compiler as gcc-linux which is not an exe file

So how do we set this up with codeblocks?

MortenMacFly:

--- Quote from: adityagameprogrammer on April 18, 2011, 10:58:40 am ---So how do we set this up with codeblocks?

--- End quote ---
If it is not a exe file it requires a wrapper tool to run on Windows, like e.g. the bash.

So what you need to do is to call the same wrapper instead of the compiler directly. You could e.g. setup a batch file for this purpose, if possible.

How does Cygwin call this file? Could it be that it is actually a proper executable but the extension is missing? If so, just make a copy of this/these file(s) and add the extension.

adityagameprogrammer:
@Morten
you are right about the path's aspect. i have checked the path of the files being called and i nagivated to the exe to this folder.

--- Code: ---C:\cygwin\opt\crosstool\i686-unknown-linux-gnu\gcc-2.95.3-glibc-2.1.3\bin
--- End code ---
and set the compiler tool chain to the exes in this folder. i.e

--- Code: ---cpp.exe
gcov.exe
gdb.exe
i686-unknown-linux-gnu-addr2line.exe
i686-unknown-linux-gnu-ar.exe
i686-unknown-linux-gnu-as.exe
i686-unknown-linux-gnu-c++.exe
i686-unknown-linux-gnu-c++filt.exe
i686-unknown-linux-gnu-g++.exe
i686-unknown-linux-gnu-gcc.exe
i686-unknown-linux-gnu-gprof.exe
i686-unknown-linux-gnu-ld.exe
i686-unknown-linux-gnu-nm.exe
i686-unknown-linux-gnu-objcopy.exe
i686-unknown-linux-gnu-objdump.exe
i686-unknown-linux-gnu-protoize.exe
i686-unknown-linux-gnu-ranlib.exe
i686-unknown-linux-gnu-readelf.exe
i686-unknown-linux-gnu-size.exe
i686-unknown-linux-gnu-strings.exe
i686-unknown-linux-gnu-strip.exe
i686-unknown-linux-gnu-unprotoize.exe
make.exe
windres.exe

--- End code ---

But the build fails.

--- Code: ---
-------------- Build: Debug in greet ---------------

[ 50.0%] Compiling: main.c
Execution of 'i686-unknown-linux-gnu-gcc.exe -Wall  -g     -c D:/Aditya/cppnix/greet/main.c -o obj/Debug/main.o' in 'D:\Aditya\cppnix\greet' failed.
Nothing to be done.

--- End code ---

I did try with the  make,windres and gdb from the mingw folders. and only the compilers pointing towards crosscompile exes. even that did not work.
I have both mingw and cygwin set up.

MortenMacFly:

--- Quote from: adityagameprogrammer on April 18, 2011, 12:27:56 pm ---you are right about the path's aspect. i have checked the path of the files being called and i nagivated to the exe to this folder.

--- Code: ---C:\cygwin\opt\crosstool\i686-unknown-linux-gnu\gcc-2.95.3-glibc-2.1.3\bin
--- End code ---
and set the compiler tool chain to the exes in this folder. i.e

--- Code: ---Execution of 'i686-unknown-linux-gnu-gcc.exe -Wall  -g     -c D:/Aditya/cppnix/greet/main.c -o obj/Debug/main.o' in 'D:\Aditya\cppnix\greet' failed.
--- End code ---

--- End quote ---
This cannot work, as the toolchain path is most likely unknown. You can (however), add the path to these executables into the toolchain options.

Settings -> compiler -> Toolchain executables -> tab "Additional paths", add C:\cygwin\opt\crosstool\i686-unknown-linux-gnu\gcc-2.95.3-glibc-2.1.3\bin there, maybe others are needed, too.

However, I doubt this is the right way. I still believe Cygwin uses a wrapper (e.g. calling the default gcc with certain options) that actually invokes these cross compile tools.

Navigation

[0] Message Index

Go to full version