Compiling Multiple .libs error

Started by
1 comment, last by ApochPiQ 6 years, 8 months ago

I have a library that is split up into 3 parts right now: a utilities lib, platform lib, and a renderer. I want them all the be their own separate .dll and .lib files. My issue is that I cannot seem to get VS to output all the files. My batch file looks like this:

 



@echo off
cls

set sable_dir=W:\dev\c\sable_lib
set src_dir=%sable_dir%\src
set deps_dir=%sable_dir%\deps

set macros=/DSABLE_LIB_EXPORT
set compiler_flags=/LDd /Zi
set linker_flags=/DLL /DEBUG

set sable_lib_libs=
set sable_lib_source_files=%src_dir%\sable_lib\sable_lib.c
set sable_lib_output=sable_lib.dll

set sable_platform_libs=sable_lib.lib %deps_dir%\sdl2\lib\x64\SDL2main.lib %deps_dir%\sdl2\lib\x64\SDL2.lib
set sable_platform_source_files=%src_dir%\sable_lib\sable_platform.c
set sable_platform_output=sable_platform.dll

set sable_renderer_libs=sable_lib.lib sable_platform.lib %deps_dir%\sdl2\lib\x64\SDL2main.lib %deps_dir%\sdl2\lib\x64\SDL2.lib %deps_dir%\sdl2\lib\x64\SDL2_image.lib
set sable_renderer_source_files=%src_dir%\sable_lib\sable_renderer.c %src_dir%\sable_lib\sera\sera.c
set sable_renderer_output=sable_renderer.dll

pushd W:\dev\c\sable_lib\bin

call "C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/vcvarsall.bat" x64

echo. 
echo BUILDING SABLE_LIB
echo. 
cl %compiler_flags% /Fe%sable_lib_output% %macros% %sable_lib_source_files% %sable_lib_libs% /link %linker_flags%

echo. 
echo BUILDING SABLE_PLATFORM
echo. 
cl %compiler_flags% /Fe%sable_platform_output% %macros% %sable_platform_source_files% %sable_platform_libs% /link %linker_flags%

echo. 
echo BUILDING SABLE_RENDERER
echo. 
cl %compiler_flags% /Fe%sable_renderer_output% %macros% %sable_renderer_source_files% %sable_renderer_libs% /link %linker_flags%

popd

 

When the first CL runs it outputs the sable_lib.lib file then sable_lib.dll, which is what I want. Then when cl runs again it outputs sable_platform.dll and sable_lib.lib not sable_platform.lib. Why is this? sable_renderer will not compile without sable_platform.lib. I'm compiling it using sublime text 3's build systems to run the batch file. This is the output:

 


 
BUILDING SABLE_LIB
 
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

sable_lib.c
Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/dll 
/implib:sable_lib.lib 
/debug 
/out:sable_lib.dll 
/DLL 
/DEBUG 
sable_lib.obj 
   Creating library sable_lib.lib and object sable_lib.exp
 
BUILDING SABLE_PLATFORM
 
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

sable_platform.c
Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/dll 
/implib:sable_platform.lib 
/debug 
/out:sable_platform.dll 
/DLL 
/DEBUG 
sable_platform.obj 
sable_lib.lib 
W:\dev\c\sable_lib\deps\sdl2\lib\x64\SDL2main.lib 
W:\dev\c\sable_lib\deps\sdl2\lib\x64\SDL2.lib 
 
BUILDING SABLE_RENDERER
 
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

sable_renderer.c
sera.c
Generating Code...
Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/dll 
/implib:sable_renderer.lib 
/debug 
/out:sable_renderer.dll 
/DLL 
/DEBUG 
sable_renderer.obj 
sera.obj 
sable_lib.lib 
sable_platform.lib 
W:\dev\c\sable_lib\deps\sdl2\lib\x64\SDL2main.lib 
W:\dev\c\sable_lib\deps\sdl2\lib\x64\SDL2.lib 
W:\dev\c\sable_lib\deps\sdl2\lib\x64\SDL2_image.lib 
LINK : fatal error LNK1104: cannot open file 'sable_platform.lib'
[Finished in 2.1s]

 

Advertisement

Assuming you've checked the obvious (does sable_platform.lib get emitted someplace you weren't expecting?) the next thing to do is turn on verbose output from LINK.EXE and go through what exactly it's doing with your DLLs.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement