Weird compiler error.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Weird compiler error.

  1. #1
    Join Date
    Jun 2008
    Posts
    8

    Weird compiler error.

    I have defined a class and it's implementation in 2 seperate files, as the following:
    (Server.h & Server.cpp are in a different project, and main.cpp is on a different one under one single solution - Visual Studio 2008)

    Server.cpp:
    Code:
    Networking::Server::Server(boost::asio::io_service& io_service_, tcp::endpoint& serverEndpoint) : 
    				io_service(io_service_), conAcceptor(io_service_, serverEndpoint)
    {
    	this->BeginAccept();
    }
    
    some other code in here.
    Server.h:
    Code:
    namespace Networking
    {
    	class Server
    	{
    		some other code...
    	public:
    		Server(boost::asio::io_service& io_service_, tcp::endpoint& serverEndpoint);
                    some other code...
    	};
    }
    and main.cpp:
    Code:
    boost::asio::io_service io;
    	Networking::Server server(io, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 5555));
    	boost::thread(boost::bind(&boost::asio::io_service::run, &io));
    When I try to compile it says that there's an unresolved external:
    Code:
    main.obj : error LNK2019: unresolved external symbol "public: __thiscall Networking::Server::Server(class boost::asio::io_service &,class boost::asio::ip::basic_endpoint<class boost::asio::ip::tcp> &)" (??0Server@Networking@@QAE@AAVio_service@asio@boost@@AAV?$basic_endpoint@Vtcp@ip@asio@boost@@@ip@34@@Z) referenced in function _main
    C:\Documents and Settings\ניב\שולחן העבודה\DESKTOP 10\RemoteDesktopBoost\Debug\FileSharing.exe : fatal error LNK1120: 1 unresolved externals

    I seriously have no idea what is the problem in here, and I wouldn't care for some help.
    Thanks in advance.
    Last edited by eXeCuTeR; May 15th, 2010 at 03:10 PM.

  2. #2
    Join Date
    Jun 2008
    Posts
    8

    Re: Weird compiler error.

    Managed to fix it by moving it to one project unfortunately.

  3. #3
    Join Date
    Aug 2007
    Posts
    858

    Re: Weird compiler error.

    If you want them to be in separate projects you'll need to have the first project (with the networking/server stuff) output a static or dynamic library, then have the second project link with that library.

  4. #4
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,893

    Re: Weird compiler error.

    In Visual Studio, you don't need to specify the library output by project 1 explicitly as a lib input to project 2; you can simply set a Project Dependency in the solution instead.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center