1

I have installed sndfile from the Mega-Nerd website. After installing it I tried adding it to the Code Blocks using this method:

How do I link to a library with Code::Blocks?

The program still does not see the methods defined in the library giving me the error:

C:\Users\Blanka\Desktop\asdasdasd\main.c|13|undefined reference to `sf_open'| ||error: ld returned 1 exit status|

I am providing paths to library, giving the compiling flags and manually pasting the header files inside the project folder, nothing helps. The problem is that it sees other functions/variables from the sndfile.h header, for example SF_INFO and SF_FORMAT_WAVE.

I have succeeded installing the library on Ubuntu, however I need to install it on Windows now.

alpereira7
  • 1,522
  • 3
  • 17
  • 30
Kokos34
  • 67
  • 1
  • 11
  • 1
    _" am providing paths to library"_ - Well did you explicitly tell it which libraries to link? Just telling it where libraries reside is not enough, – Captain Obvlious May 06 '16 at 19:07
  • Do you mean explicitly providing path to library .lib file? – Kokos34 May 06 '16 at 19:11
  • No, I asked if you specified which libraries to link. You told it where to find them but did actually configure it to link them. – Captain Obvlious May 06 '16 at 19:28
  • 1
    Configure Code Blocks to link them? Yes, I did. I added library file in linker in Code Blocks properties. – Kokos34 May 06 '16 at 20:17
  • To get help with a linkage failure you need to post at least the failing linker command, and the errors that follow from it, verbatim from the build log. You will find these in the Code::Blocks **Build log** tab (not the **Build messages** tab) after the build fails, The failing linker command is the last `g++ ...` command in the build log. It is followed by the errors. – Mike Kinghan May 07 '16 at 06:43
  • What version of libsndfile did you chose on mega-nerd.com website? 32bit or 64bit? – alpereira7 Nov 14 '18 at 11:24

2 Answers2

0

Try to use visual studio. snffile windows installer just put 'libsndfile-1.lib' into the dest, but coodblocks needs .a to link for the mingw.

Hsinyu
  • 1
0

The good news is SF_INFO and SF_FORMAT_WAVE are recognized, so this means that your header file is correctly read. I see you have copied the header into your project, but a suggested proper way to do it is detailed in this answer.

I confirm you can link .lib files to Code::Blocks and I suppose you have made it properly:

lib

A common error I saw in various forums, and I also made, is to have downloaded the 64 bit version of libsndfile instead of the 32 bit one. Code::Blocks is oftenly downloaded with mingw, which includes GCC compiling in 32 bit and most beginning users are unaware of that.

So considering you have all linked properly, I suggest you confirm the compiler is 32 (or 64) bit and download the 32 (or 64) bit version of libsndfile.

alpereira7
  • 1,522
  • 3
  • 17
  • 30