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.
Related
C++ GUI Tutorial: undefined reference to TextOut
I have the same problem, but I'm new to programming and Code::Blocks, and I want to use the GDI32 library. How can I install it? I'm very confused because I can use the windows.h header, but some functions like TextOut aren't available.
The gdi32 library is already installed on your computer, few programs will run without it. Your compiler will (if installed properly) normally come with an import library, which is what the linker uses to make a binding between your program and the file in the system. (In the unlikely case that your compiler does not come with import libraries for the system libs, you will need to download the Microsoft Windows Platform SDK.)
To link with gdi32:
This will reliably work with MinGW-gcc for all system libraries (it should work if you use any other compiler too, but I can't talk about things I've not tried). You can also write the library's full name, but writing libgdi32.a has no advantage over gdi32 other than being more type work.
If it does not work for some reason, you may have to provide a different name (for example the library is named gdi32.lib for MSVC).
For libraries in some odd locations or project subfolders, you will need to provide a proper pathname (click on the "..." button for a file select dialog).
You can create new with project win32 gui api it has default add library -lgdi32 -luser32 -lkernel32 -lcomctl32 -mwindows or add library -mwindows in your project, it worked for me.
At a guess, you used Code::Blocks to create a Console Application project. Such a project does not link in the GDI stuff, because console applications are generally not intended to do graphics, and TextOut is a graphics function. If you want to use the features of the GDI, you should create a Win32 Gui Project, which will be set up to link in the GDI for you.
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.
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.
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.
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.