g++ error: can't map file, errno=22 or the case of the missing space

Alec Jacobson

March 01, 2010

weblog/

I was trying to build and opencv hello world program from the command line with g++ and I got a funny error. When I issued the compile command the site had listed:
g++ hello-world.cpp -o hello-world -I /opt/local/include/opencv -L /opt/local/lib -lcxcore -lm -lcv -lhighgui -lcvaux
it would crash with:
ld: in /opt/local/lib, can't map file, errno=22
After some fruitless searching, I realized it was just the space between -L and /opt/local/lib. I removed the space:
g++ hello-world.cpp -o hello-world -I /opt/local/include/opencv -L/opt/local/lib -lcxcore -lm -lcv -lhighgui -lcvaux
And everything worked!