Why do I need a * .obj file with static binding?

I am not sure why this is so. I am distributing static * .lib to several projects, but this static lib generates many * .obj files. It looks like I need to distribute * .obj files with * .lib as well. Otherwise, I get this error:

1>LINK : fatal error LNK1181: cannot open input file 'nsglCore.obj'

Why is this? Is there a way to include data in * .obj files in * .lib? Maybe a switch in the compiler?

This is my configuration for a static library:

C / C ++

/Od /GT /D "WIN32" /D "NDEBUG" /D "_LIB" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /MD /Yu"stdafx.hpp" /Fp"e:\Development\Projects\nsGameLib\Source\Core\Intermediate\nsglCore-Win32-Release.pch" /Fo"e:\Development\Projects\nsGameLib\Source\Core\Intermediate\\" /Fd"e:\Development\Projects\nsGameLib\Source\Core\Intermediate\vc90-Release.pdb" /W3 /nologo /c /Zi /TP /errorReport:prompt

Librarian

/OUT:"e:\Development\Projects\nsGameLib\Source\Core\Output\nsglCore-Win32-Release.lib" /NOLOGO /LTCG

This is my configuration for a project using a static library:

C / C ++

/O2 /Oi /I "E:\Development\Projects\nsGameLib\Samples\\DummyEngine\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /FD /EHsc /MD /Gy /Fo"e:\Development\Projects\nsGameLib\Samples\OnlyCore\Intermediate\\" /Fd"e:\Development\Projects\nsGameLib\Samples\OnlyCore\Intermediate\vc90-Release.pdb" /W3 /nologo /c /Zi /TP /errorReport:prompt

Linker

/OUT:"e:\Development\Projects\nsGameLib\Samples\OnlyCore\Output\SampleOnlyCore-Win32-Release.exe" /INCREMENTAL:NO /NOLOGO /LIBPATH:"E:\Development\Projects\nsGameLib\Samples\..\Deployment\Libraries" /MANIFEST /MANIFESTFILE:"e:\Development\Projects\nsGameLib\Samples\OnlyCore\Intermediate\SampleOnlyCore-Win32-Release.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"e:\Development\Projects\nsGameLib\Samples\OnlyCore\Intermediate\SampleOnlyCore-Win32-Release.pdb" /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /LTCG /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT nsglCore  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
+5
source share
3 answers

, . .lib. , nsglCore nsglCore-Win32-Release.lib , , nsglCore-$(TargetPlatform)-$(ConfigurationName).lib .

+5

, . , .

UNIXy, ( , VS , ).

:

gcc -c -o prog.o prog.c
gcc -o prog prog.o -L/libdir -lstdc

C. , , , , :

  • .o .
  • , referenced-but- undefined.

, , prog.c printf("hello\n");. prog.o, printf, .

, . /libdir/libstdc.ext :

  • /libdir - -L ( ).
  • /lib .
  • stdc - ( -L).
  • ext - (.a, .so, .sl ..).

, . , /libdir/libstdc.a(printf.o), /libdir/libstdc.a(putch.o).

, , . VS , ( , MSVC).

+4

... .

, lib,

| Linker

: Dependancy Library - No

This is a Visual Studio option to capture .obj files directly, not a .lib file. I assume this is necessary to avoid the link step and thus speed up compilation.

In general, you should install a project that creates the lib file as a function of the project that uses it (under the general properties in this properties window). Then you include the library library dependencies. In most cases, this works well.

+3
source

All Articles