Making exe-file in c portable - static linking [duplicate] - c

I have installed GCC and GTK+. Its working fine, but i need to statically link GTK+ libraries with my application (it's a small application) so that there exist only one '.exe'.

mingw-cross-env has fixes to build gtk and all related libs statically

It is supported with a few minor issues (like having trouble finding configuration files), but you will have to compile GTK+ yourself! (the default binaries do not include static libraries)
See this mailing-list thread for more information on this issue.

The correct answer would be two words: not supported. Really, if you want to distribute your application, being it 2 or 100000 lines, just bind a copy of GTK+ with it.

Related

Organizing a pure-C project so it can be built using GUI tools on different platforms

I am planning to start updating some old-ish C code to C99, hosted publicly on GitHub. The code compiles without a single change on Linux, macOS and Windows.
To ease poking about in the code, on my Mac I used an Xcode project file to organize it. I believe other users might find this useful too, and on .Net as well.
So, my question is purely organizational - does anyone out there have a canonical example of how to arrange such a project physically? That is, a widely used example that has Mac, Win and Linux builds using platform specific project files and make/make config
I know can just put the project files in subfolders, but I want to be sure that if there is a "standard" way to do this that I use it too.

gcc find installed libraries

Is there a way to list all the installed libraries and/or query if a specific library is installed with gcc? I want to know if glut is available on my system (without browsing all the library path).
I am using mingw w/ gcc 4.5.2 under windows.
The way to check will generally be platform and compiler dependent. Getting it 100% right is hard.
You can use a build system like CMake for generating your actual build system (confused yet ;-)?)
I found a small tutorial which explains how to find glut for you. Essentially, all you need is
find_package(GLUT)
in your CMakeLists.txt. To get to know cmake, I suggest you read/follow their tutorial
I believe your best bet is to try to compile and link a simple example.
Gcc will complain about any libraries it can't find.
You may also try to use a smart IDE (CDT) and try to auto-complete your #include statement. That may as well list all your installed libs.

Using static libraries on a C project in XCode 4.5.2

I'm new to Xcode so not really keen on it yet. In my college is used visual studio to program in C in which they create a solution and fill it with an application and then include static libraries with .h and .c files. Been trying to do this in Xcode but can't seem to include them or add dependencies like in Visual Studio
One approach is just using the standard gcc command line options for static library linking which you can specify using the XCode project settings. This will work if the static library is installed and accessible in the standard locations.
Alternatively you can add a static library explicitly to your project and set the dependencies and search paths for headers etc appropriately. This may sound a bit involved, but there's not really that much to do, and you only need to set it up once. It's all done in the same place as other project settings, and you can use the search box to find exactly where to enter the options.
I'm assuming you don't want to actually build the static library with your project. if you do there's more to do - basically you need to set up the static library project, set it as a target dependency, and setup a build step to copy the resulting library.

Adding GraphicsMagick to an Xcode project

I have created a Foundation Tool in Xcode, and want to use some functions from the GraphicsMagick image manipulation library. The library has been compiled and installed on my computer using MacPorts. I added libGraphicsMagick.3.dylib and libGraphicsMagickWand.2.dylib to my project as external frameworks.
What other steps must I take to use these libraries in my application, and how would I import their headers to use their functions in my code?
Thanks
UPDATE: Made some progress. Used the .a static libraries instead of the dylibs, added them to my project, then added the header files for magick and wand. I'm trying to compile, but I get this error:
alt text http://cl.ly/f4233cddbae23e1a19fc/content
Searched around a bit, and apparently this problem occurs because 2 of the typedef enum declarations that GraphicsMagick and ImageMagick use are already defined in OS X framework headers. The enums in question are ColorInfo and ExceptionInfo.
The only way to fix it is to go through the source and rename every occurance of those enums to a new name that isn't already taken. However, the iPhone does not have this issue and GraphicsMagick will compile just fine. Unfortunately, I don't think the people behind the library are willing to rename their enums just to get it to compile on OS X.

Compiling a C library so it can be used in an iPhone static library

I've never done this before, so I'm not sure where to even start. I have a few projects where I want to use the liblio library, both on the iPhone and OS X. I've put the installation instructions in a gist.
Here are my questions, and I'll try and edit these questions as I figure them out.
Do I want to use make install to compile these files? I feel like all the compilation should be done within XCode.
It looks like there are a lot of platform specific settings during compilation. How do I control this from XCode?
It seems like I should be able to add all the .h/.m files to my XCode project and compile them myself. Is this missing something?
For the record, I'm aware of a few LibLO libraries created for use on the iPhone. I may break down and use one, but I'd prefer to learn how to do this myself.
Yes, if you want to compile these projects from within XCode, you need to add the .c/.h files and then setup them accordingly. XCode has support for passing argument to the compiler of course, so it is indeed possible.
From the gist snippet, it looks like the installation instructions are GNU standard instructions, ie. configure; make; make install. You could try playing with arguments to configure (which, btw, creates the Makefile on the spot) and see what options you have for compiling to a different target platform.
However, it may not be worth all the trouble to convert the Makefile's to a pure XCode project. Another approach, which I think I would start with, is to hack the created Makefile until you are able to compile an iPhone friendly lib-file. After that you can tell XCode to run 'make ...' as part of your projects build steps. Then, once you understand the issues, it may be easier to include them in your XCode project proper.
I have not tried this myself, but Building autoconf-configured libraries for iPhone OS might have some useful information for you.

Resources