I am trying to build a C project in Visual C++ 2010 Express as C++ so I can create a C++/CLI .net wrapper for it. It compiles fine, but the linker tells me that swprintf(…), vswprintf(…), _swprintf_l(…), and _vswprintf(…) are already defined. The strange thing is that it says they are already defined in an .obj file that I made, and I am sure that I did not define them. In fact, I don’t even call any of them. Does anyone have any idea what could be causing this?
Some clarifications:
This library is being written in straight C and built and run in OS X, FreeBSD, OpenBSD, and Linux. Porting it to Windows as a .net assembly is the challenge. I read that C libraries must be built in C++ to be given a C++/CLI wrapper. In getting it to build as a C++ project, I had to make a few tweaks (such as malloc casting) but it should still maintain C compatibility.
* FINAL UPDATE *
I don’t know how many hours I have wasted trying to make a .net wrapper for the file parsing library I am writing. I have tried it several times and every time it fails miserably. This time I did get farther than ever before, but I still could not get it to work.
What I had originally envisioned was a 3 project solution:
- an unmanaged static libary, built in C
- a managed .net wrapper, built in C++/CLI
- a managed winforms app, built in C#
I quickly learned that the express editions of Visual Studio give you exactly what you pay for them and don’t allow you to mix projects of different languages in a single solution. In order to do that, I would have to pay $800 for VS Pro and that is NOT happening!
I adapted to this by deciding to write the simple app in C++/CLI. Even so, it simply would not work. Apparently, I would either have to link the .obj files from part 1 (which doesn’t work, because it cannot compile C files with /clr) or build part 2 with /clr:safe (which created all kinds of other problems).
I really don’t know if this is a limitation of the useless Express editions of VS or if this would even be possible with the absurdly expensive versions (strange that $800 gets you VS Pro, but $700 gets you all of XCode and a Mac Mini to run in on! Microsoft Dev Tax anyone?!?) but either way, I’ve had enough. My library works great in OS X, FreeBSD, OpenBSD, Linux, and OpenSolaris, but not Windows, and until MS releases free dev tools that are actually useful and actually provide a way to use PORTABLE code (this works in), I just won’t care.
Thanks to all of you who gave advice and tried to help.
jorj
you can use the preprocess-to-file option. This will tell you quickly where the function come from !
May be you’re using the _tcs-versions of them ?