Cross Compilation for C applications using Eclipse - c

I'm developing a java application which uses native code with JNI, so I developped a C shared library using Eclipse with the CDT plugin on Linux Redhat. Everything works fine since I can launch my java application and call the native methods without any problem. But my problem is, I need to compile my code on every platform (Linux, Windows, x86/x64). It's not a problem to get the libXXX.so file but I also need a .dll to run on Windows, except I can't just compile my code on it, I need a way to do that locally on Linux with Eclipse. So I am looking for some simple solutions to do that locally with Eclipse using cross compilation.
I've made some researches but I can't find a real tutorial to explain how to do that, each time people say to compile on the specified platform. So if someone could help me with this that would be great.
My configuration is : Linux RedHat, Eclipse Juno, CDT plugin 8.1

You need a Linux -> Windows cross compiler. The MinGW tools would do the job, but, last I checked, they only provide binary downloads to run on Windows (i.e. not a cross-compiler). There are some (old) instructions for building your own here.
The CodeBench compiler is probably exactly what you want, but it's not free (there is a free trial though). It's basically a professional build of the MinGW tools, and comes with it's own customized Eclipse so there's no fiddling about needed in that department.
A quick google also comes up with these tools on sourceforge, but I've not tried them.

Related

Using different GCC to build Linux vs Linux Apps

This question may seem weird for some gurus out there, but I'm a little perplexed.
Basically what I want to do is to evaluate different tool chain for developing applications on embedded Linux. Say I have my Linux built using Yocto Project, which cross-compiles GCC from scratch can provide it as a cross toolchain for apps developers.
But if I want to try out different toolchains fro this point, say Sourcery CodeBench or a toolchain generated using BuildRoot, is it possible to build a applications using these toolchains and still run them on the Yocto-generated Linux? I'd imagine this is doable is built statically. But if we then want to link dynamically, it's simply a matter of copying over libc?
Thanks for the help. Sorry if question is ambiguous.

Dos.h + Pc.h in C and Windows Vista

I am currently looking to work with Mesa3D to create a software rendered graphic application with OpenGL.
I am looking a a few tutorials right now on how to use it, and many are written with DOS or older versions of Windows in mind. As I run Vista I don't seem to have the right files I need.
The Mesa3D tutorial I am using uses outportb() and a few other commands which I can't seem to get working. After looking around I have found you require the 2 include files:
dos.h
pc.h
These do not seem to be found within the Window's SDK that comes with Visual Studio 2010 (Express) or even the older version of 2005 (Professional) which I currently have.
They seem to be found with the DJGPP compiler that only works under DOS and is not supported in Vista, even with compatability mode. Running DosBox still does not get this to work.
I am wondering - is there perhaps a new functions replacing outportb or can I use these DJGPP files with my C/C++ complier with VS or PellesC (which I find better for C-only programs)?
In addition the conio.h include file I have with both VS and PellesC doesn't have the textmode() function, but the DJGPP version does.
If anyone could help either getting DJGPP working on Vista or allowing me to use the dos,pc and conio.h files from DJGPP with either VS or PellesC that'd be a great help!
Port-manipulating functions will simply not work in Win32 programs. Either use Win32 APIs to do I/O (rendering included) or stick to DOS and run your program in DOS or whatever DOS emulator you can find that works. Vista and later Windows won't run most DOS programs directly as the support for DOS is either severely reduced or removed altogether (e.g. in 64-bit Windows).
The low-level hardware access that functions like outportb give you is not available to programs in modern Windows environments. Such capabilities are reserved for specially-trusted code (OS internals and drivers). You need to go through higher-level APIs or drivers in order to access the same functionality.
The Mesa3D website has a readme for Windows developers that has information about what you need to install and configure. It also references some official demo code that you can use as the basis for your project. The Mesa3D website also has a repository full of demo programs that will probably serve as better examples than the out-of-date tutorials that you mentioned.
Do not use 16bit compilers on vista and higher.. instead use DOSBOX to run your programs.

how do i install custom c++ libraries?

i'm taking a computer security class and i was hoping i can get some pointers on how to install custom libraries the professor had uploaded. the main language is C which i am not very familiar with. i am using eclipse for c/c++.
if eclipse is not a great choice for c please direct me to the best program for c.
installing these libraries in my laptop is not required because its already installed in the labs in school but i'd prefer it if i could do thing on my own laptop.
thanks!
ps: reason i like eclipse is because of the alignment command it has =/
using window 7 64bit...
http://www-cs.ccny.cuny.edu/~fazio/F11-csc48000/lab0/install-libs.html
here is my prof's website for the lab...
Download a free copy of Virtual Box.
Install the same linux distro that your class uses in it.
Run eclipse in there, and just do what your professor tells you to for those libraries.
Any attempt to do this on native Windows will cost you more time that you can possibly afford.

How do I install Eclipse for C

How do I install Eclipse for C
Please send links and helpful tips.
Thanks
Need an easy install
• Steps involved
• SDK with all the libraries and stuff I'll need
• Variable path setup
• Anything else that may surprise a noob
I use the following plug-in which allows me to develop in both C and C++
Eclipse CDT
There are tutorials and instructions on how to download on the website, so if you have any other questions, let me know!
I've never used Eclipse for C or C++ (I have only used it for Java) and I'm guessing its just a simple install: http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/heliosr
As far as I know, everything you'll need comes pre-packaged and configures itself as part of the installation. You'll need the JRE if you don't have it though.
I suggest going with MS Visual C++ express instead especially if you are on Windows. The reason is that getting the GNU C compiler installed with Eclipse on Windows is a real pain.
I did it once and don't even remember since it's a bit of work to get Cygwin — which provides a Linux®-like environment on Windows installed. Not as easy and clear as it should be i.e. not just a point and click install like Eclipse with Java. I have a feeling not many people try installing it on Windows since the install documentation seems more geared towards the Linux where with many distro's gcc is already installed or a simple install.

Good IDE/compiler for simple C dll's

I'm trying to disassemble a C/C++ DLL, and have made some progress, but I would like to create my own C DLL with the same function the original exports, and compare disassemblies.
Visual Studio adds to much crap, and when I remove the crap and build my project, the expected DLL is missing.
I need a lightweight, preferably IDE, tool to edit and build very simple C libraries.
Take a look at Code::Blocks
I need a lightweight, preferably IDE, tool to edit and build very simple C libraries.
I have found that one of the best ways to do integrated C-only Win32 development is using the freely available Lcc Win32 Compiler which comes with a built-in IDE, including resource editor.
In fact, it is really very lightweight and can be run from a USB stick with some manual tweaking.
It's indeed a really small download of just 6 mb and you can even download an optional Win32 API help file which is really useful while doing development.
The compiler also comes with a C tutorial, as well as good user documentation detailing how to use the integrated Win32 resource editor "wedit", there's also an advanced manual about more complex development tasks.
Dev-C++ is a nice and fast IDE which works well with MingW.
But it's all been asked and answered before ...
MinGW adds its own crap. Install your VC express properly and save yourself a lifetime of trouble.
Btw, you don't need to use Visual Studio for its compiler or vice versa. The oddity of missing a build dll is probably because you are not looking at the right path.
If you are building C DLLs you really would benefit from its command line toolset and utilities, sdks, easy config etc. MS lock-in proprietary extensions are widely used (in context of you trying to emulate another dll), and last thing you need is chasing cross compiler issues..
GCC + any text editor such as VIM is a very light alternative.
For Windows Development, all you need is inside MinGW
Edit: If you are in dire need of an IDE you can also use the MinGW tools from Eclipse with the CDT plugin. Although it adds weight to the solution because of the installation of Eclipse, this is what I really use to build my small DLLs (JNI wrappers in my case).
You can setup your small and direct makefiles or let Eclipse do it automatically for you and concentrate only on the source files (*.h, *.c).
The best part of using this approach instead other IDE is that you do not need Eclipse to further build the DLL, since the underlying project files generated are standard ones directly usable by integrated dev inside MinGW (or any Unix distro) such as make, configure, automake, and so on.
I'll second the vote for Code::Blocks, it's what I use (despite having VS 2008 installed as well). It is very simple and lightweight but has basically all the features you'd expect out of an IDE. It comes with several predefined project templates for all kinds of C and C++ development, including templates for DLLs.
Download the version that includes MinGW and you get a complete lightweight IDE ready to start compiling. You can also easily configure it to use the Visual Studio compiler instead of gcc if you prefer.
try Open Watcom. A cross-platform product, well-supported by the community, lets you develop in DOS, Windows, OS/2 etc for a lot of platforms. Version 1.8 was released recently. Has a light-weight IDE indeed

Resources