Jump to content
  • Advertisement
Sign in to follow this  
gretty

Link Outside Library in VS2013

This topic is 799 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to link an outside library in my C++ VS2013 project. Upon compiling the project I get the error:
 

 Error    1    error LNK2019: unresolved external symbol "void __cdecl bar(void)" (?bar@@YAXXZ) referenced in function _main    D:\Projects\IncludeOutsideLib\main.obj    IncludeOutsideLib

I have setup Configuration Properties->C/C++->Additional Include Directories to point to the outside library folder`$(PROJECTDIR)/../Foo/`. Is there anything else I need to do?

The project/directory structure is very simple
 

Projects:
    Foo:
        foo.h
        foo.cpp
    IncludeOutsideLib:
        // contains C++ VS2013 project
        main.cpp

foo.h:

   #ifndef FOO_H
    #define FOO_H

    #include <cstdlib>

    void bar();

    #endif // FOO_H

foo.cpp:

#include "foo.h"

    void bar()
    {
        printf("bar\n");
    }

main.cpp:

#include <iostream>
    #include <cstdlib>
    #include "foo.h"

    int main(int argc, char** argv)
    {
        bar();
        system("pause");
        return 0;
    }
Edited by gretty

Share this post


Link to post
Share on other sites
Advertisement

You need your main project to link to the .lib file that you generated.

 

The best way is to make the lib project a dependency of the main project (Project menu -> Project Dependencies... and set up the main project to Depend On the lib project). Then make sure your main project has the Link Dependencies option enabled (Project properties -> Linker section -> set Link Library Dependencies to Yes).

 

 

That should fix the problem.

Share this post


Link to post
Share on other sites

I believe you can now add libs as resources in the Solution Explorer as well. I know that works in 2015CE.

 

It's nice for local libs but not so nice for system libs. I wish they'd improve that a bit more. I hate digging around in the properties pages.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!