0

This is about work-flow / ease of managing Visual Studio project.

Project Structure

I have a solution that contains 2 projects.

Structure 1

  • project B (static-library) : Use function from an external library (e.g. Bullet3d)

    • include Bullet's header
    • link to Bullet's .lib (roughly speaking)*
  • project C (application) : Use function/class from B, never touch Bullet directly
    • include B's header
    • link to B's .obj

[*] As far as I know, a static library doesn't concern about what it links (+another similar link).
The above tree just describes what I want.

As I tested, the above structure causes unresolved external symbol error.

Structure 2

It works OK. Here is the structure :-

  • project B :

    • include Bullet's header
  • project C :

    • include B's header
    • link to B's .obj <------ X
    • link to Bullet's .lib <------ Y

The X can be done easily in VS2015 :-

  • Right click the word References of C in Solution explorer".
  • Then, add B.

The Y can be done by setting C's project property or (more advance) manipulate property sheet that C uses.

Question

Although structure 2 works, it is inconvenient and not intuitive for me.
Whenever a project (e.g. C) want to import B, I will also have to do Y ,
i.e. manually link C to "Bullet's library" (.lib).

Is there any technical approach/work-around (syntactic sugar of work-flow) that enable structure 1?

More specifically, I want a way to mark B as "Any one who refer to me will automatically link to Bullet's .lib".

Reference

There are many similar questions but these below questions are about X (project inside my solution) but not Y (automatically link to external project that is not a part of my solution).

Note: ar-command does not help, because ar is Linux-specific.

Community
  • 1
  • 1
javaLover
  • 6,347
  • 2
  • 22
  • 67
  • 1
    You can use `#pragma comment(lib, "acme.lib")` to the source, but this requires that your libs are somehow on the library search path. You could alternatively use the properties editor to create a vsprops file that can add additional library directories, but again, people could forget to add the vsprops file to their projects. – Chris Becke Mar 28 '17 at 11:31
  • Can vs create relocatable object files? – Daniel Jour Mar 28 '17 at 11:34
  • @Chris Becke Thank, [`#pragma comment`](http://stackoverflow.com/questions/3484434/what-does-pragma-comment-mean) is very useful. I never heard about it. XD – javaLover Mar 28 '17 at 11:35
  • @Daniel Jour I don't know what "relocatable object files" means. I am still very new to project/solution concept, and also Visual Studio. My knowledge about Visual Studio is probably a subset of yours. – javaLover Mar 28 '17 at 11:37

0 Answers0