kripken/emscripten — Issue #268: -Ldir Clang Warning: argument unused during compilation
Author: peterleecomcn
Created: 2012-02-21 19:54:55+00:00
State: open

Hi,

I cannot compile with `_Ldir` (Add directory dir to the list of directories to be searched for `-l`.)

This issue can be reproduced by the following steps:

## Step 1. Compile the SPEEX lib using emscripten:

```
cd /home/plee/Dev/emscripten/tests/
wget http://downloads.xiph.org/releases/speex/speex-1.2rc1.tar.gz
tar -zxvf speex-1.2rc1.tar.gz
cd speex-1.2rc1/
emconfigure ./configure
make
```

Now, the `libspeex.a` is generated under `/home/plee/Dev/emscripten/tests/speex-1.2rc1/libspeex/.libs/`;

## Step 2. Create a minimized test program with SPEEX:
Contents in `SpeexWrapper.cpp`:

```cpp
extern "C"
{
#include
#include

// Get the frame size (number of samples, NOT bytes)
void SpeexTest()
{
SpeexMode mode = speex_wb_mode; // speex_wb_mode is a global const defined in speex/speex.h
void* state = speex_decoder_init(&mode);
int frameSize = 0;
speex_decoder_ctl(state, SPEEX_GET_FRAME_SIZE, &frameSize);
speex_decoder_destroy(state);

printf("WideBand Mode FrameSize: %d\n", frameSize);
}

}

int main(int argc, char* argv[])
{
SpeexTest();

return 0;
}
```

## Step 3: Compile the `SpeexWrapper.cpp` AND `libspeex.a`

```
plee@sos:~/EclipseCDT-IndigoWorkspace/SpeexWrapper/src$ emcc -O0 SpeexWrapper.cpp /home/plee/Dev/emscripten/tests/speex-1.2rc1/libspeex/.libs/libspeex.a -o SpeexWrapper.js -I/home/plee/Dev/emscripten/tests/speex-1.2rc1/include
plee@sos:~/EclipseCDT-IndigoWorkspace/SpeexWrapper/src$ node SpeexWrapper.js
WideBand Mode FrameSize: 320
```

Everything is great, but if we do

```
plee@sos:~/EclipseCDT-IndigoWorkspace/SpeexWrapper/src$ emcc -O0 SpeexWrapper.cpp -lspeex -L/home/plee/Dev/emscripten/tests/speex-1.2rc1/libspeex/.libs/ -o SpeexWrapper.js -I/home/plee/Dev/emscripten/tests/speex-1.2rc1/include
clang: warning: -lspeex: 'linker' input unused when '-c' is present
clang: warning: argument unused during compilation: '-L/home/plee/Dev/emscripten/tests/speex-1.2rc1/libspeex/.libs/'
plee@sos:~/EclipseCDT-IndigoWorkspace/SpeexWrapper/src$ node SpeexWrapper.js

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: undefined is not a function
at _SpeexTest (/home/plee/EclipseCDT-IndigoWorkspace/SpeexWrapper/src/SpeexWrapper.js:805:10)
at _main (/home/plee/EclipseCDT-IndigoWorkspace/SpeexWrapper/src/SpeexWrapper.js:830:3)
at Object.callMain (/home/plee/EclipseCDT-IndigoWorkspace/SpeexWrapper/src/SpeexWrapper.js:1723:10)
at run (/home/plee/EclipseCDT-IndigoWorkspace/SpeexWrapper/src/SpeexWrapper.js:1740:18)
at Object. (/home/plee/EclipseCDT-IndigoWorkspace/SpeexWrapper/src/SpeexWrapper.js:1755:13)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
```

CC @kripken @paleozogt