Jump to content
  • Advertisement
Sign in to follow this  
codical

linking libraries in ms visual c++ xpress 08

This topic is 3985 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

Hi all, I'm new here. nice message font. Anyway, I'm used to using the pdCurses lib and SDL with dev-cpp IDE but recently started using visual c++ express 2008. Since dev-cpp had a download manager (devPak) I never have needed to learn how to link libs for use with my projects. So I really need to get some basic knowledge in this area. If for example I wanted to link up SDL/TTF/SDL_Mixer/pdCurses etc,etc HOW THE HELL DO I DO IT !? I read a previous reply to op by pulpfist (I think pulpfist), on how to link up pdCurse 3.3 for ms Visual express 2008. I followed the instructions but there were multiple definitions with a microsoft DLL and missing symbols. Can I get some basic directions for linking third party libs please ? thanks for your time.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Since dev-cpp had a download manager (devPak) I never have needed to learn how to link libs for use with my projects.
Well, the DevPaks did two things. They installed a library and the necessary binaries (most libraries are distributed as source). Then they also add to Dev-C++ a “quickstart” configuration. So I’m guessing you relied on this project configuration quickstart instead of starting with an empty project, and manually adding the libraries yourself.

Which brings me to another point. Can you even compile a library yourself? You say you have pdCurses and SDL with you. But is it just the source or did you actual compile them to binaries?

Share this post


Link to post
Share on other sites
Quote:
Which brings me to another point. Can you even compile a library yourself? You say you have pdCurses and SDL with you. But is it just the source or did you actual compile them to binaries?


To the first question I have to say no.

I can compile my own projects and include my own header files.
On dev-cpp I could use SDL and pdCurses, but I never needed to manually build and link them.

Share this post


Link to post
Share on other sites
I don't know about pdCurses, but you can download pre-compiled SDL libs off their website. Once you have the .lib files and the headers, there's really three things you need to do:

-Specify which .lib files you're linking to. This is in project settings->linker->input->additional dependencies

-Make sure the .lib file is somewhere where Visual Studio knows where to look for them. This means you can either put them on the libs folder in your VC8 installation folder, or specify another folder in either your project settings or your global VC++ settings.

-Do the same for the header files, put them somewhere VC++ already looks or specify the directory in your settings.

Share this post


Link to post
Share on other sites
To add to mjp's post
to tell VS where to find a library it is linker > general > additional library directories
and for the includes it is c++ > general > additional include dirs

Share this post


Link to post
Share on other sites
So I have done the following.

I downloaded precompiled pdcurses 3.3

I put the headers into the VC include folder
I put the lib file into VC lib folder
I put the pdcurses DLL into the VC bin folder.

Then I typed...
(I dont know where this forums code tags are)

// main source file

#include <curses.h>
#include <ctime>
#include <cstdlib>
#include <iostream>
#include "c_event.h" // my header
#include "c_depref.h" // my header
#include "DataVar.h" // my header

#define COLOR1 1
#define COLOR2 2

int main()
{
unsigned int seed = time(NULL) ;
srand( seed ) ;

initscr ();
resize_term (150,90) ;
cbreak ();
noecho ();
start_color ();
keypad (stdscr, TRUE);
curs_set(0);

init_pair (COLOR1, COLOR_RED, COLOR_BLUE);
attron (COLOR_PAIR (COLOR1)) ;

printw ("hi") ;
refresh ();

getch();
endwin ();
return 0;
}

The Build output reads...

Linking...
LINK : C:\Documents and Settings\coder\My Documents\Visual Studio 2008\Projects\dynamicLib\Debug\ChAoS.exe not found or not built by the last incremental link; performing full link
ChAoS.obj : error LNK2019: unresolved external symbol _wgetch referenced in function _main
ChAoS.obj : error LNK2019: unresolved external symbol _refresh referenced in function _main
ChAoS.obj : error LNK2019: unresolved external symbol _printw referenced in function _main
ChAoS.obj : error LNK2019: unresolved external symbol _init_pair referenced in function _main
ChAoS.obj : error LNK2019: unresolved external symbol _endwin referenced in function _main
ChAoS.obj : error LNK2019: unresolved external symbol _has_colors referenced in function _main
ChAoS.obj : error LNK2019: unresolved external symbol _curs_set referenced in function _main
ChAoS.obj : error LNK2019: unresolved external symbol _keypad referenced in function _main
ChAoS.obj : error LNK2001: unresolved external symbol __imp__stdscr
ChAoS.obj : error LNK2019: unresolved external symbol _start_color referenced in function _main
ChAoS.obj : error LNK2019: unresolved external symbol _noecho referenced in function _main
ChAoS.obj : error LNK2019: unresolved external symbol _cbreak referenced in function _main
ChAoS.obj : error LNK2019: unresolved external symbol _resize_term referenced in function _main
ChAoS.obj : error LNK2019: unresolved external symbol _initscr referenced in function _main
C:\Documents and Settings\coder\My Documents\Visual Studio 2008\Projects\dynamicLib\Debug\ChAoS.exe : fatal error LNK1120: 14 unresolved externals
Build log was saved at "file://c:\Documents and Settings\coder\My Documents\Visual Studio 2008\Projects\dynamicLib\ChAoS\Debug\BuildLog.htm"
ChAoS - 15 error(s), 2 warning(s)
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========

Can anyone help me !?

Share this post


Link to post
Share on other sites
You need to add the pdcurses library file to the list of additional libraries to link to in the Project's Linker options.

edit - as MJP stated earlier.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!