HydrogenAudio

Hosted Forums => foobar2000 => Development - (fb2k) => Topic started by: Axonn on 2014-10-24 09:49:47

Title: Linker errors trying to compile foo_sample
Post by: Axonn on 2014-10-24 09:49:47
Hello there .

So I finally found time to create some FooBar components . My first target is to create a component which writes the songs I play into a text file. I need this for another application I’m developing.

Unfortunately, I haven’t touched Visual C++ in quite a few years and I’ve stumbled upon what probably is a very simple error that almost any developer around here can help me with. Yes, you guessed it, it’s a linker error.

I’m using Visual Studio 2010 and trying to compile foo_sample. I, of course, tried to fix this error. I went into Project Properties -> Linker -> Additional Library Directories and I added the “Debug” folder where I put all the libs which I compiled from the other foobar projects. I also added the foobar “shared” includes to “Additional Include Directories” in C++ -> General.

Still, I’m getting a ton of linker errors:

http://pastebin.com/uH2c1x7U (http://pastebin.com/uH2c1x7U)

I should also mention that I don’t really see how WTL fits into all this. I mean, sure, I know what it is, but it doesn’t seem to produce any lib. I just added its folder, along SDK and helpers to the “Additional Include Directories”.

Can you please help me start up this foo_sample so that I can start oiling my rusty C++ joints and get this component coding going? .
Title: Linker errors trying to compile foo_sample
Post by: lvqcl on 2014-10-24 15:32:46
Add shared.lib file to Linker -> Input -> Additional Dependencies
Title: Linker errors trying to compile foo_sample
Post by: Axonn on 2014-10-24 15:40:43
LOL and that was it! . Such a tiny thing. *aaaaargh* .

*presses huge "Thank you lvqcl" button*.
Title: Linker errors trying to compile foo_sample
Post by: Axonn on 2014-10-27 10:38:01
Ouch. Now I'm running into another linker error when trying to build the Release version

http://pastebin.com/4Fn6yQnr (http://pastebin.com/4Fn6yQnr)

What does it want to say with this?

1>LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library

It also hits me with a warning that it doesn't generate a PCH:

IntelliSense: PCH warning: header stop cannot be in a macro or #if block.  An intellisense PCH file was not generated.   e:\tools\b0.foobar\sdk\foobar2000\shared\shared.h   40

This is the code which it complains about, at the "extern" statement.

#ifndef SHARED_EXPORTS
#define SHARED_EXPORT __declspec(dllimport) SHARED_API
#else
#define SHARED_EXPORT __declspec(dllexport) SHARED_API
#endif

extern "C" {

P.S.: I copied the /INCREMENTAL from the Debug configuration.
Title: Linker errors trying to compile foo_sample
Post by: foosion on 2014-10-27 13:17:01
1>LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
Check the C++ code generation settings to make sure you don't use the debug version of the C/C++ runtime for the release build.
Title: Linker errors trying to compile foo_sample
Post by: Axonn on 2014-10-27 13:51:05
C/C++ -> Code Generation -> Runtime library is set to "Multi-threaded (/MT)"
Title: Linker errors trying to compile foo_sample
Post by: foosion on 2014-10-27 18:46:13
I checked your first post again. This seems to be the problem:
I went into Project Properties -> Linker -> Additional Library Directories and I added the “Debug” folder where I put all the libs which I compiled from the other foobar projects.
You can automatically add the output of another project as input if you add the other project as a reference ("Frameworks and references" in the project properties). The IDE will take care to consistently use the debug or release versions.
Title: Linker errors trying to compile foo_sample
Post by: Axonn on 2014-10-28 11:41:34
Yay! It finally works . Thank you foosion, and again thanks lvqcl.

I should mention that simply specifying "shared.lib" in Linker, Input, Additional Dependencies is not enough. It is also required to go to "General" and specify Additional Library Directories and add the shared's directory there, which is quite DUUUH when you think about it, but unfortunately I've been away from the C++ side of Visual Studio for FAAAAAR to long (about 5 years to be precise).