0
  • I've added the bin folder to system PATH as well "libsndfile-1.dll" to the main directory of the program.

  • I've linked the include directories and added the "libsndfile-1.lib" library from codeblocks's library linker.

  • I've made and linked additional .as from the dll and from the original definition file. Because it will complain otherwise.


After I've discovered that the header file does not define a function implied in the vast amount of examples.. I ran a program that only contains refers to the available functions. https://github.com/michaelwu/libsndfile/blob/master/examples/sfprocess.c Of course, something will not work again, because when I ran the program it threw the runtime error : The application was unable to start correctly (0xc000007b)


What am I missing now?

Imobilis
  • 1,475
  • 8
  • 29
  • First you have to be sure that the command line is correct. You can change the CB configuration to show you the command line, It is in the user manual (http://www.codeblocks.org/docs/manual_en.pdf) "1.11.6 Extended settings for compilers". Also I think that you can give a custom command line for both compile and link (see 1.9 3.5 and 3.6). – terence hill Dec 14 '15 at 21:15
  • The command line appears to be ultimately long.. maybe, because of the installations of gtk and several modules. The only unusual thing I could notice is that it uses `-ID` and `-LD` instead of `-I` and `-L` ..hence unusual but not wrong yeah. – Imobilis Dec 15 '15 at 06:37
  • Did you chek that the order is correct? Anyway I suggest you to post it. – terence hill Dec 15 '15 at 10:17
  • This "warning: implicit declaration of function 'sf_open_read'" implies that the compiler could not find the header where the function is declared. It searches the header here: D:\apps\libsndfile\include (the D is just the Drive name). Check this path and see if there are the correct .h files. – terence hill Dec 15 '15 at 10:48
  • Okay for some reason the header file doesn't define that particular function but a lot other similar. So I'd assume that the examples are severely outdated. Using another function, compiles but throws a runtime error: The application was unable to start correctly.. – Imobilis Dec 15 '15 at 10:59
  • I guess you should update the question. – terence hill Dec 15 '15 at 11:01
  • I guess that library sucks... it greatly lacks working examples.... – Imobilis Dec 15 '15 at 11:11

3 Answers3

1

The error you encountered states that the application is 32 bit and attempted to load a 64 bit library (see NTSTATUS) or vice versa.

You should install the correct library: the 32 bit version if your system is 32 bit or the 64 bit version if your system is 64 bit. Form here seems that both version can be downloaded.

terence hill
  • 3,354
  • 18
  • 31
1

Validate the command-line, preferably compile manually.

Make sure ALL the modules are from the x64 bit pre-compilation (they differ in size in the slightest), the static and dynamic libraries, including the .a you've made. The NTSTATUS error usually will occur when only a module is for use in x32 bit systems, but not the entire library. This truly matters in Audio Programming, because it very depends on it as you can conclude from the direct sound processing. So it's not really the library's fault.

Don't install it with MSYS.

..and you don't have to append -lsndfile in the command line as long as you've linked all the libraries from within CB.

Edenia
  • 2,312
  • 1
  • 16
  • 33
0

Order matters!

You want to use:

gcc -I D:\apps\libsndfile\include\ main.c -o testexec -L D:\apps\libsndfile\lib\ -lsndfile 

For your reference

alk
  • 69,737
  • 10
  • 105
  • 255
  • Unfortunately, I only objectified it. I use CB's library linker. CB doesn't have such a command line and it keeps me blindfold of what the command line actually is. – Imobilis Dec 12 '15 at 09:18
  • Try replacing the back-slashes by slashes. @Malina – alk Dec 12 '15 at 09:20
  • I tried to compile outside CB, manually with this command line and linker returned error : "cannot find -lsndfile" – Imobilis Dec 12 '15 at 09:21
  • 1
    If the library file is called `libsndfile-1.*` you want to use `-lsndfile-1` @Malina – alk Dec 12 '15 at 09:23
  • It still cannot find it. This is odd, I have installed myself GTK+3 as well as the module gtksourceview, but am failing to install this small library. – Imobilis Dec 12 '15 at 09:25
  • Also you probably not need to add the path to the `libsendfile-1.dll`, but to `libsndfile-1.lib`, which is the import library used for linking. The `*.dll` version is used during run-time only. @Malina – alk Dec 12 '15 at 09:27
  • The dll is copied in the program's local dir and the directory in which it is located (by default in bin) is added in PATH. – Imobilis Dec 12 '15 at 09:29
  • Typically there is a tool around which would create the .lib for the .dll. Read on "import library to link against dll". – alk Dec 12 '15 at 09:30
  • So there is another .lib file I need to create and link ? – Imobilis Dec 12 '15 at 09:31
  • Also related: http://www.mingw.org/wiki/specify_the_libraries_for_the_linker_to_use @Malina – alk Dec 12 '15 at 09:35
  • The library dir already contain some `libsndfile.def` in lib. – Imobilis Dec 12 '15 at 09:37
  • Well I create dll from the one existing and the one created from the existing dll, linked the output `*.a`'s and it still complains of being unable to find `-llibsndfile-1` – Imobilis Dec 12 '15 at 10:01
  • It ought to be `-lsndfile...`, not `-llibsndfile...`! @Malina – alk Dec 12 '15 at 10:02
  • According to the page you sent me, it got to be be `-llibsndfile` – Imobilis Dec 12 '15 at 10:24
  • `-l` the name is `libsndfile-1` so it must be `-llibsndfile-1` .... but of course I will test it either way and it will still not work. – Imobilis Dec 12 '15 at 10:25
  • From the links I provided: "*The linker searches [...] for the **library**, which is actually a file named lib**library**...*" @Malina – alk Dec 12 '15 at 12:23