Using FreeImage with Xcode - macos

I'm writing an application in which I want to use free image to load files. I am on MacOSX 10.8.2 and I am using the mac ports version of free image. I had it working, but when I tried putting it on another computer without the port, it wouldn't run because it didn't have the files. The macports version comes with a dylib, can I use that to run it without downloading the port? If I can how would I compile it with the project because I have tried linking it as a Binary Library, but I can't include the files. Any help would be appreciated, as I have bee at this for a few hours now.
Thanks

You can actually build the FreeImage library as a static library. Unfortunately, the downloadable source from the http://freeimage.sourceforge.net/download.html website uses makefiles that are expecting to use the older SDKs for Xcode3.
I actually updated the Makefile.osx to build with Xcode4 using the 10.7 SDK and posted the change to https://gist.github.com/AhiyaHiya/5105571
You should be able to run this make from Terminal.app and create your .dylib and .a files for your needs.

Related

Linker error building Adobe DNG SDK on MacOS 11

I am working on a project that uses Adobe's DNG SDK 1.6 library, and it is supposed to work on Windows and MacOS.
The library has instructions on how to build it for both platforms, but I had to figure out an error that came up on Windows with Visual Studio. I am not very experienced with big C++ projects so it was not trivial but I got it working. Most of my own code will be done in C# .Net Core, calling the native libraries using a wrapper class with P/Invoke.
Now for Mac that's a different story, I have a MacOS 11 VM, installed Xcode 12.5.1 and followed the steps provided, as expected, it does not work. Bare in mind this is my first time touching Xcode and MacOS.
The project I am trying to build is dng_validate, and it depends on two libraries built by these projects: XMPFiles64 and XMPCore64.
The library projects build without any hiccups, each one of them creating a ".a" file in the folder: dng_sdk_1_6/xmp/toolkit/public/libraries/macintosh/intel_64_libcpp/Debug, they are named libXMPFilesStaticDebug.a and libXMPCoreStaticDebug.a respectively.
When I try to build the dng_validate project, I get the following error:
Library not found for -lXMPFilesStaticDebug
Because of the the error starting with an "l" instead of "lib", under both libraries project settings, I changed the "Executable Prefix" setting to "l" instead of "lib". Rebuilt both of them and made sure the file names changed as expected. But the error persists when trying to build the main project.
Under dng_validate's project settings, there is a setting called "Library Search Paths" and it does point to the proper aforementioned folder using a relative path. I even changed it to an absolute path to see if that would make it work.
I am really lost here, does anyone have an idea of what might be causing it?
Well... After asking on other forums and almost hiring a freelancer to fix this for me, I tried another shot in the dark of renaming the library files and it worked.
I changed the extensions of libXMPFilesStaticDebug.a and libXMPCoreStaticDebug.a from ".a" to ".dylib" and it just compiled and blew my mind with it.

wxwidgets platform.h error: no such file or directory wx/setup.h

I am using Code::Blocks with wxwidgets and I have include and lib folders under Document\wxwidgets. I am very new to c++ libraries. In Code::Blocks project initialization, I entered the location for wxwidgets. Then in setting/global enviornment variables I entered in base the Document\wxwidgets again. Still, I am not able to run the app. It shows the error in the include/wx/platform.h file where it says
C:\Users\Programming coder\Documents\wxwidgets\include\wx\platform.h|148|fatal error: wx/setup.h: No such file or directory|
I am not able to solve this and would appreciate some help. Also I checked and the wx folder does not seem to be there in the location. I don't know if that is normal.
Also, I downloaded the headers(include) from the wxwidgets github repo download page, wxWidgets-3.1.1-headers.7z. Any help appreciated.
Also, I am aware some questions exist already, but their problems are in different because most are using linux. Also I am using Code::Blocks IDE.
You need to build wxWidgets itself before building the applications using it. Its build process will create the setup.h file which is currently missing.
Note that, in principle, you could also use precompiled binaries, but in this case you must use exactly the same compiler as was used for compiling them, i.e. TDM gcc.

Xcode Cocoa app libav* and MagickWand static library issues

I've been developing a Cocoa app that uses both the libav* and ImageMagick C libraries but am having issues actually distributing the app. I have linked to the various static libraries in Xcode like so:
The app builds and runs perfectly fine on my machine. Now I am trying to run it on a different computer. I archived the build, and exported it as a macOS app in Xcode, which leaves me with the .app archive. Now, when I try to run it on a different mac, I get the following error:
If I run otool -L binary_name on the built binary, I get a .dylib for every single one of the included .a files. I thought the whole point of a static library was that it gets built into main binary, and that there is then no need to do any dynamic linking. Why is it still trying to load the dylib?
I managed to resolve this issue, and believe it was due to the technical note listed here: Using static versions of existing dynamic libraries. Since the dependencies I am using were installed via homebrew, the lib folders of each dependency had both the .a and .dylib files, and Xcode was linking using the dylibs. To fix it, I copied all the .a files that I needed to a separate folder and adjusted my Library Search Paths in Xcode to point to the new folder. The app now builds and links to the static libraries as it should.

Using libusb in open frameworks on OS X

I wanted to try some things with openFrameworks but got stuck trying to use libusb, which is not available as of addon.
I copied it in the "other" folder but don't no how to include it in the project.
The included ofxKinect addon includes compiled libusb and headers. If you add that add-on via the project generator, you'll have access to libusb.

wx/setup.h file not found on XCode 4

i'm trying to make work wxWidgets on OS X 10.8 with XCode 4. So far i've managed to build the library in static mode.
I'm currently trying to add the library to a basic "hello world" sample project.
For that, i follow a tutorial that explain step by step the process.
I'm stuck though on a simple error : can't find "wx/setup.h"
i've check the derivedData folder where is the .a library and there is no setup.h
I had one setup.h created when i compiled wxWidgets using the Terminal (but i had other errors this way after, so i had to switch to XCode wxWidgets generation.)
where is the generated setup.h when building wxWidgets from XCode ? and how do i tell the compiler to use it?
I've never compiled wxWidgets under OS X using Xcode so I can't help you with finding the file (however I do wonder if you tried find . -name setup.h or using Spotlight?), but I can guarantee that the library compiled from the command line is compatible with the applications built using Xcode, provided you use the same compiler and runtime library for both. So if you already have a version built from the Terminal, you really should be able to just use it.

Resources