Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Linker errors trying to compile foo_sample (Read 3923 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Linker errors trying to compile foo_sample

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

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? .

Linker errors trying to compile foo_sample

Reply #1
Add shared.lib file to Linker -> Input -> Additional Dependencies

Linker errors trying to compile foo_sample

Reply #2
LOL and that was it! . Such a tiny thing. *aaaaargh* .

*presses huge "Thank you lvqcl" button*.

Linker errors trying to compile foo_sample

Reply #3
Ouch. Now I'm running into another linker error when trying to build the Release version

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.

Linker errors trying to compile foo_sample

Reply #4
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.

Linker errors trying to compile foo_sample

Reply #5
C/C++ -> Code Generation -> Runtime library is set to "Multi-threaded (/MT)"

Linker errors trying to compile foo_sample

Reply #6
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.

 

Linker errors trying to compile foo_sample

Reply #7
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).