Telling gcc directly to link a library statically

Use -l: instead of -l. For example -l:libXYZ.a to link with libXYZ.a. Notice the lib and .a are written out, as opposed to -lXYZ which would auto-expand to libXYZ.so/libXYZ.a. It is an option of the GNU ld linker: -l namespec … If namespec is of the form :filename, ld will search the library path for a file called filename, otherwise it will search the library path for a file called libnamespec.a. … on ELF … systems, ld will search a directory … Read more

Why does fatal error “LNK1104: cannot open file ‘C:\Program.obj'” occur when I compile a C++ project in Visual Studio?

This particular issue is caused by specifying a dependency to a lib file that had spaces in its path. The path needs to be surrounded by quotes for the project to compile correctly. On the Configuration Properties -> Linker -> Input tab of the project’s properties, there is an Additional Dependencies property. This issue was fixed by adding the … Read more

“Multiple definition of” C++ compiler error

Why do you #include lines.cpp in ThreeD.cpp? This is very unusual. Your makefile wants lines.o, so you’re going to compile lines.cpp. Anything defined in lines.cpp will be in lines.o and also in ThreeD.o. There is an intriguing comment in lines.cpp: I think the instructor wants you to break lines.cpp into a .h and a .cpp. … Read more