Sign in to follow this  

C++ Compiling Multiple .libs error

Recommended Posts

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

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 mister345
      Hi, can somebody please tell me in clear simple steps how to debug and step through an hlsl shader file?
      I already did Debug > Start Graphics Debugging > then captured some frames from Visual Studio and
      double clicked on the frame to open it, but no idea where to go from there.
       
      I've been searching for hours and there's no information on this, not even on the Microsoft Website!
      They say "open the  Graphics Pixel History window" but there is no such window!
      Then they say, in the "Pipeline Stages choose Start Debugging"  but the Start Debugging option is nowhere to be found in the whole interface.
      Also, how do I even open the hlsl file that I want to set a break point in from inside the Graphics Debugger?
       
      All I want to do is set a break point in a specific hlsl file, step thru it, and see the data, but this is so unbelievably complicated
      and Microsoft's instructions are horrible! Somebody please, please help.
       
       
       

    • By Kirlim
      I'm working a lot with identifiers types to help me while debugging or managing collections of instances in my code. Previously, I had using directives as the following example code:
      using AnimalId = unsigned int; using TreeId = unsigned int;  
      After a while, I accidentally mixed AnimalId and TreeId in my logic, so I've decided to use structs in order to make the identifiers strong typed. To avoid code duplications, I've created a template
      template <typename TypeTag, typename ValueType> struct IdType { ValueType value; // Methods for comparison and hashes };  
      However, I believe there's two different ways of using this template:
      // Using directive struct AnimalIdTag {} using AnimalId = IdType<AnimalIdTag, unsigned int>; // Inheritance struct TreeId : IdType<TreeId, unsigned int>;  
      And here is where I got in doubt. It seems both ways are valid, but there should be some differences. For example, with inheritance I can forward declare the TreeId on headers, which doesn't seem really feasible (in a painless way) with AnimalId. However, TreeId uses inheritance, and my knowledge on how inheritance and templates works "in background" is too weak to say, but it feels like there might be some hidden drawback.
      Are there differences to make deciding which one to use easier? Or there's currently no drawbacks (besides being able to forward declare or not)?
    • By komires
      We are pleased to announce the release of Matali Physics 4.0, the fourth major version of Matali Physics engine.
      What is Matali Physics?
      Matali Physics is an advanced, multi-platform, high-performance 3d physics engine intended for games, virtual reality and physics-based simulations. Matali Physics and add-ons form physics environment which provides complex physical simulation and physics-based modeling of objects both real and imagined. The engine is available across multiple platforms:
              Android         *BSD         iOS         Linux         OS X         SteamOS         Windows 10 UAP/UWP         Windows 7/8/8.1/10         Windows XP/Vista What's new in version 4.0?
               One extended edition of Matali Physics engine          Support for Android 8.0 Oreo, iOS 11.x and macOS High Sierra (version 10.13.x) as well as support for the latest IDEs          Matali Render 3.0 add-on with physically-based rendering (PBR), screen space ambient occlusion (SSAO) and support for Vulkan API          Matali Games add-on  
      Main benefits of using Matali Physics:
              Stable, high-performance solution supplied together with the rich set of add-ons for all major mobile and desktop platforms (both 32 and 64 bit)         Advanced samples ready to use in your own games         New features on request         Dedicated technical support         Regular updates and fixes
      The engine history in a nutshell
      Matali Physics was built in 2009 as a dedicated solution for XNA. The first complete version of the engine was released in November 2010, and it was further developed to July 2014 forming multi-platform, fully manage solution for .NET and Mono. In the meantime, from October 2013 to July 2014, was introduced simultaneous support for C++. A significant change occurred in July 2014 together with the release of version 3.0. Managed version of the engine has been abandoned, and the engine was released solely with a new native core written entirely in modern C++. Currently the engine is intensively developed as an advanced, cross-platform, high-performance 3d physics solution.
       
      If you have questions related to the latest update or use of Matali Physics engine as a stable physics solution in your projects, please don't hesitate to contact us.

      View full story
    • By Manumeq
      Hello everyone.
      Me and a bunch of classmates are making a videogame from scratch in c++. We are currently using the Irrlicht Engine in our code, but will begin to develop our own engine in a couple of weeks. One of our concerns right now is the User Interface.
      After doing some research, I found several libraries for creating a GUI in c++, problem is in the past we have spent more time learning and figuring out how to make things work with libraries than we would have if we actually made the entire code from scratch ourselves.
      So, I wanted to ask more experienced game programmers out there, what would be your preferred choice? using a library or writting the code from scratch when making an UI, and in case of the libraries, which ones would you use?.
      Heres what we will most likely do:
      Healthbars Displaying numbers in HUD Displaying icons (images) in HUD Drawing game menu elements (text and rectangles) Also, we are currently working in linux, more specifically Manjaro KDE and without IDE's (using our own make file and the console).
      PD: Sorry in advance is this is in the wrong topic, It's my first time asking a question in GameDev.net
    • By isu diss
      I implemented the paper, Numerical Methods for Mie Theory of Scattering by a Sphere, Link:https://prints.iiap.res.in/bitstream/2248/72/1/Numerical Methods for Mie Theory of Scattering by a Sphere.pdf
      Unfortunately, my implementation is not accurate. I couldn't find any mistakes in my code. Can anyone help me?
      struct XMDOUBLE2 { double x; double y; XMDOUBLE2() {} XMDOUBLE2(double _x, double _y) : x(_x), y(_y) {} explicit XMDOUBLE2(_In_reads_(2) const double *pArray) : x(pArray[0]), y(pArray[1]) {} XMDOUBLE2& operator= (const XMFLOAT2& Float2) { x = Float2.x; y = Float2.y; return *this; } }; XMDOUBLE2 Complex_Add(XMDOUBLE2 z1, XMDOUBLE2 z2)// z1 + z2 { return XMDOUBLE2((z1.x + z2.x), (z1.y + z2.y)); } XMDOUBLE2 Complex_Subtract(XMDOUBLE2 z1, XMDOUBLE2 z2)// z1 - z2 { return XMDOUBLE2((z1.x - z2.x), (z1.y - z2.y)); } XMDOUBLE2 Complex_Multiply(XMDOUBLE2 z1, XMDOUBLE2 z2)// z1*z2 { return XMDOUBLE2(((z1.x*z2.x) - (z1.y*z2.y)), ((z1.x*z2.y) + (z1.y*z2.x))); } double Complex_Norm(XMDOUBLE2 z)// |z| { return sqrt((z.x*z.x) + (z.y*z.y)); } XMDOUBLE2 Complex_Division(XMDOUBLE2 z1, XMDOUBLE2 z2)// z1/z2 { XMDOUBLE2 tmp; if (Complex_Norm(z2) != 0) { tmp.x = ((z1.x*z2.x)+(z1.y*z2.y))/((z2.x*z2.x)+(z2.y*z2.y)); tmp.y = ((z1.y*z2.x)-(z1.x*z2.y))/((z2.x*z2.x)+(z2.y*z2.y)); } return tmp; } //m = 1.5+i0.0 void MieCoefficient(XMDOUBLE2 m, float r, float Lamda)//m = (m')+i(-m"): complex index of refraction, r: radius of the spherical particle in um, lamda: wavelength in nm { #define TOTAL_MAX_TERMS 2100 double Alpha[TOTAL_MAX_TERMS], Beta[TOTAL_MAX_TERMS], P[TOTAL_MAX_TERMS], Q[TOTAL_MAX_TERMS], R[TOTAL_MAX_TERMS], S[TOTAL_MAX_TERMS], B[TOTAL_MAX_TERMS], C[TOTAL_MAX_TERMS], C_[TOTAL_MAX_TERMS]; XMDOUBLE2 A[TOTAL_MAX_TERMS], G[TOTAL_MAX_TERMS], H[TOTAL_MAX_TERMS], a[TOTAL_MAX_TERMS], b[TOTAL_MAX_TERMS]; for (int n=0; n<TOTAL_MAX_TERMS; n++) { Alpha[n] = 0; Beta[n] = 0; P[n] = 0; Q[n] = 0; R[n] = 0; S[n] = 0; B[n] = 0; C[n] = 0; C_[n] = 0; A[n] = XMDOUBLE2(0, 0); G[n] = XMDOUBLE2(0, 0); H[n] = XMDOUBLE2(0, 0); a[n] = XMDOUBLE2(0, 0); b[n] = XMDOUBLE2(0, 0); } // float Lamdaum = (float)Lamda*1e-3; float x = 23.1f;//((2*XM_PI*r) / Lamdaum); //int MAX_TERMS = (int)(x + 7.5f*pow(x, .34f) + 2); int MAX_TERMS = (int)(x + 4*pow(x, 0.33f) + 2); //Wiscombe if (MAX_TERMS<TOTAL_MAX_TERMS) { double y1 = x*m.x; double y2 = x*m.y; XMDOUBLE2 z = XMDOUBLE2(y1, y2); double zNorm = Complex_Norm(z); double y = zNorm*zNorm; for (int n=MAX_TERMS; n>0; n--) { Alpha[n] = ((((2*(double)(n))-1)*y1) / y) - P[n]; Beta[n] = ((((2*(double)(n))-1)*y2) / y) + Q[n]; P[n-1] = (Alpha[n] / ((Alpha[n]*Alpha[n]) + (Beta[n]*Beta[n]))); Q[n-1] = (Beta[n] / ((Alpha[n]*Alpha[n]) + (Beta[n]*Beta[n]))); R[n-1] = (x / (((2*(double)(n))-1) - (x*R[n]))); } S[0] = sin(x); for (int n=1; n<MAX_TERMS; n++) { S[n] = R[n]*S[n-1]; } for (int n=0; n<MAX_TERMS; n++) { XMDOUBLE2 t1 = Complex_Division(XMDOUBLE2(1.0f, 0), XMDOUBLE2(P[n], Q[n])); XMDOUBLE2 t2 = Complex_Division(XMDOUBLE2((double)(n), 0), z); A[n] = Complex_Subtract(t1, t2); B[n] = (((1/R[n]) - ((double)(n)/x))); } C[0] = cos(x); C[1] = ((cos(x)/x) + sin(x)); for (int n=2; n<MAX_TERMS; n++) { C[n] = (((((2*(double)(n))-1) / x) * C[n-1]) - C[n-2]); } C_[0] = 0; for (int n=1; n<MAX_TERMS; n++) { C_[n] = (((((double)(-n)) / x) * C[n]) - C[n-1]); } for (int n=0; n<MAX_TERMS; n++) { G[n] = XMDOUBLE2(1, (C[n]/S[n])); H[n] = XMDOUBLE2(B[n], (C_[n]/S[n])); } for (int n=0; n<MAX_TERMS; n++) { XMDOUBLE2 t1 = Complex_Multiply(m, XMDOUBLE2(B[n], 0)); XMDOUBLE2 t2 = Complex_Multiply(A[n], G[n]); XMDOUBLE2 t3 = Complex_Multiply(m, H[n]); a[n] = Complex_Division(Complex_Subtract(A[n], t1), Complex_Subtract(t2, t3)); XMDOUBLE2 t4 = Complex_Multiply(m, A[n]); XMDOUBLE2 t5 = Complex_Multiply(t4, G[n]); b[n] = Complex_Division(Complex_Subtract(t4, XMDOUBLE2(B[n], 0)), Complex_Subtract(t5, H[n])); } double Qext = 0, tmp = 0; for (int n=0; n<MAX_TERMS; n++) { tmp += (((2*(double)(n))+1) * Complex_Add(a[n], b[n]).x); } Qext = ((tmp*2) / (x*x)); char s[256]; sprintf_s(s, "%.25f", Qext); MessageBoxA(0, s, "", MB_OK); } }  
  • Popular Now