Unable to link a C library from ofApp

Hi all,

I’ve spent several hours trying to link a library written in C. The library runs perfectly in an example outside of OF. In the example, the library is included with:

#include <stdio.h>
#include <windows.h>
#include "..\..\CameraLibrary\CameraLib.h"

But as soon as I include the header file from within an ofApp nothing will ever link.

The link error is the following:
fatal error LNK1169: one or more multiply defined symbols found
https://support.microsoft.com/en-us/kb/148652

The reference states that:
“These functions require the MFC libraries to be linked before the CRT library is linked.”

And I see my library being linked at the end of the linking process. I guess many other addon creators have bumped into a similar problem and have sorted it out, but I don’t seem to find the solution.

Any clues would be very helpful!
Best,

I think I just found the solution here:
https://msdn.microsoft.com/en-us/library/70abkas3.aspx

/FORCE:MULTIPLE in linker AdditionalOptions

when including c libraries from c++ you need to do:

extern "C"{
#include "..\..\CameraLibrary\CameraLib.h"
}

otherwise the symbols in that header will be mangled as C++ and when linking it will only find the C ones and it complains that it can’t find it.

Thank you Arturo.
Somehow if I do that I still get linker errors. setting /FORCE:MULTIPLE in linker options fixes it.