Sign in to follow this  
krusable

C++ Compiling Multiple .libs error

Recommended Posts

krusable    104

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]

 

Share this post


Link to post
Share on other sites
ApochPiQ    23005

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Similar Content

    • By evolvegames
      [attachment=35462:Screenshot_2017-03-29-14-34-31-692_com.EvolveGames.MinesweeperGo.png]
       
      Minesweeper Go is a variant of well-known classic minesweeper game.
       
      As opposed to classic version Minesweeper Go were designed by keeping in mind demands of professional minesweepers.
       
      Beta version of the game released on android play market and available here: Google Play
       
      Here is a small list of key features:
       
      - Game playback
      Each game is recorded and you can playback it any time you want
       
      - Advanced chording
      Chord can be applied recursively so players can achieve fastest board solving times
       
      - Personal comprehensive score board with various benchmarks.
       
      - Advanced benchmarks
      Minesweeper Go calculates players 3BV/s values, Taps count, Taps/s, RQP, IOS, IOE and some other stats that are valuable for advanced players
       
      - Explicit Non-Flagging (NF) mode
      Game is made with No-Flaggers in mind
       
      - 3BV control feature
      You can generate a custom minefield with predefined 3BV value
       
      - Online World Ranking table 
      All players can participate in World Ranking. Each player records can be viewed (and replayed) by other players to make sure of theirs authenticity
       
      - Cheats.
      Undo on fail, etc.
       
      Some of other features are in progress and will be implemented soon. Notable ones are here:
      - Tournament mode
      - Themes
      - Board save/restore
      - Playback speed tuning and rewinding options
       
      If you like it please leave your feedback on Minesweeper Go Facebook page https://www.facebook.com/minesweepergo
       
      Thanks.
       
      [attachment=35460:Screenshot_2017-03-25-17-46-03-282_com.EvolveGames.MinesweeperGo.png][attachment=35461:Screenshot_2017-03-25-17-59-09-348_com.EvolveGames.MinesweeperGo.png]
    • By MarcusAseth
      I need some help to understand what I'm doing wrong here x_x
      Here's my step:
      1) create a new C++ project with starting content, drop a door in the scene.
      2)Add a C++ component to the door called OpenDoor
      3)add a variable in the .h and initialize it in the .cpp  (code below)
      When I compile this, the editor crash and any future attempt to open the project won't succede. What mistake did I made? Furthermore, if said mistake is made, is the project lost forever or there is a way to restore it? x_x  Cause if wathever silly mistake I've made, if it's all it takes to corrupt and lose an entire project, then I'm done with Unreal Editor... x_x
      OpenDoor.h:
      // Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Components/ActorComponent.h" #include "OpenDoor.generated.h" UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) class BUILDINGESCAPE_API UOpenDoor : public UActorComponent { GENERATED_BODY() public: // Sets default values for this component's properties UOpenDoor(); protected: // Called when the game starts virtual void BeginPlay() override; public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; private: float DoorYaw; };  
      OpenDoor.cpp:
      // Fill out your copyright notice in the Description page of Project Settings. #include "OpenDoor.h" #include "GameFramework/Actor.h" // Sets default values for this component's properties UOpenDoor::UOpenDoor() :DoorYaw{GetOwner()->GetActorRotation().Yaw} { // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features // off to improve performance if you don't need them. PrimaryComponentTick.bCanEverTick = true; // ... } // Called when the game starts void UOpenDoor::BeginPlay() { Super::BeginPlay(); // ... } // Called every frame void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); // ... }  
    • By MarcusAseth
      I'm getting a "red minus icon" next to all my .h and .cpp inside of the VS 2017 solution explorer, anyone knows what does it means? It is red so it doesn't mean anything good, right?
  • Popular Now