Having trouble linking a library

datopdogg7
datopdogg7 used Ask the Experts™
on
Hi Experts,
I am trying to link the tinyxml library to my project.

Here are the steps I have done so far:

Went to project properties -> Configuration properties -> Linker.
Goto to ->General and set the "Additional Library directories"  and pointed to the folder which all of the tinyxml files are in.

Then I went to Linker -> Input and type in the file name i.e. tinyxml_lib in the "Additional Dependencies" field. I was assuming this is the library file.

This does not work. When I try to compile, I get this error:

1>Linking...
1>LINK : fatal error LNK1104: cannot open file 'tinyxml_lib.obj'
1>Build log was saved at "file://c:\Users\Dennis\Desktop\gui_2\DigitalImage\Debug\BuildLog.htm"
1>DigitalImage - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Please help.

Thanks,
Dennis
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
evilrixSenior Software Engineer (Avast)

Commented:
>> tinyxml_libShould that not be tinyxml.lib ??

Author

Commented:
unfortunately that is the name showing up in the folder.
you can donwload it here: http://sourceforge.net/projects/tinyxml/
it is only 200kb, so perhaps you can check to see what is the right name of the file I am supposed to be using.
Thanks,
Dennis
evilrixSenior Software Engineer (Avast)

Commented:
I don't use Windows, so that's probably not going to help I'm afraid. Can you do a dir redirect the output to a file and post that here for me?
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Author

Commented:
What is a dir redirect?
What if I posted a screen shot of the folder directory?
evilrixSenior Software Engineer (Avast)

Commented:
dir > output.txt

Author

Commented:
OK, what do you want me to output to the text file?
I have a list of files and it appears the one I am trying to add a dependecy to is not working.
evilrixSenior Software Engineer (Avast)

Commented:
>> OK, what do you want me to output to the text file?
I want you to just do a dir of the folder that contains the libraries and then copy/paste (or upload the txt file) here so I can see exactly what files you have. You hsould have a file that ends in .lib (or maybe many) these are the static libraries you'll probably need to link against (assuming the library has been built of course).

Author

Commented:
I can't find the option for a "dir". I know windows, but I have never seen this before.
I am just going to attach a screenshot.
screenshot.jpg
evilrixSenior Software Engineer (Avast)

Commented:
>> I can't find the option for a "dir". I know windows, but I have never seen this before.
It's a DOS command.
http://www.computerhope.com/dirhlp.htm

The reason you don't have a library is because you haven't built it. The folder you've shown me are just Visual Studio 6 projects and workspaces. You need to open the tinyxml workshare and build the projects. Visual Studio 6 is very old now, so if you don't have it but have a newer version of the compiler (currently 2008, with 2010 coming soon) you'll have to try opening it and hope the newver compilers can still build it.

First, you should switch on that Windows Explorer shows file extensions of known file types. The tinyxml_lib you supposed to represent the library file is a VC6 project file tinyxml_lib.dsp which can't be linked against. Instead, you need to double-click on either tinyxml_lib.dsp (VC6) or tinyxml.vcproj (VC7 and later) to open the project file with appropriate Visual Studio. Then, make a build on that project where in any case the output is a tinyxml_lib.lib file either in subfolder Debug or Release. You can use that .lib file to link against probably after copying it to another subfolder 'lib' or to the project folder of tinyxml.  
>>>> you'll have to try opening it and hope the newver compilers can still build it.
As told you can open the .vcproj files which were for newer versions of the VC compiler.
evilrixSenior Software Engineer (Avast)

Commented:
>> As told you can open the .vcproj files which were for newer versions of the VC compiler.
Indeed you can... but they often make a mess of VC6 workspaces :(
>>>>  but they often make a mess of VC6 workspaces :(
I mean to remember that I downloaded tinyxml myself in 2007. My compiler was VC7.1 and it worked without conversion. And the conversions are not so bad. I recently 'translated' an old VC6 (which originally comes from VC1.5, a compiler for Win32S which runs with 16bit Windows). But beside a few for loops where the counter wasn't no longer valid after loop and some *deprecated* string functions it worked just fine.
evilrixSenior Software Engineer (Avast)

Commented:
>> which originally comes from VC1.5, a compiler for Win32S which runs with 16bit Windows
Ah, yes -- I know 1.52C very well indeed as I used it for about 5 years (I was developing for a DOS handheld device and it was the last compiler to compile native DOS code). :)

There have been many breaking changes since VC7.1 -- mostly to bring the compiler up to the C/C++ standard.

Take a look.. the list is quite extensive.
http://msdn.microsoft.com/en-us/library/ms177253(VS.80).aspx
http://msdn.microsoft.com/en-us/library/ms177253(VS.80).aspx

Anyway, it might just work (I'm not gonna hold my breath though)... YMMV -- good luck ;)
>>>> I can't find the option for a "dir". I know windows, but I have never seen this before.

Type WIN + R and enter

   cmd

That opens a command window also known as dos box.

Enter

  c:

if the tinyxml project folder is on C drive or choose the right drive letter instead.

Navigate to the project folder e. g. by a command like

  cd \projects\tinyxml

if the path contains spaces you need to use double-quotes

 cd "\project files\projects\tinyxml"

Then type

  dir

what gives you the list of files in the tinyxml folder.

By

  dir > xxx.txt

all files would be *redirected* to new file xxx.txt which you could open by Visual Studio or Notepad or any editor and past the contents as code snippet. The advantage over a jpg screen shot is that all file extensions were shown and it is pure text so no graphic viewer must be used.

Author

Commented:
OK, so I built the project, which was successful.

I think linked to the tinyxml folder.
Then in the additional dependencies, i typed "tinyxml_lib" I did not put a file extension at the end.

I get the same error.
evilrixSenior Software Engineer (Avast)

Commented:
>> I get the same error.
That's because the library is probably called tinyxml.lib -- as I said right at the start.
evilrixSenior Software Engineer (Avast)

Commented:
Oh, and don't forget you also need to tell the linker where to look for the library... it needs a path too. I don't have Visual Studio to hand... Alex, can you tell datadogg where that goes please?

Author

Commented:
1>------ Build started: Project: DigitalImage, Configuration: Debug Win32 ------
1>Linking...
1>LINK : fatal error LNK1104: cannot open file 'tinyxml.lib'
1>Build log was saved at "file://c:\Users\Dennis\Desktop\GUI\DigitalImage\Debug\BuildLog.htm"
1>DigitalImage - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
evilrixSenior Software Engineer (Avast)
Commented:
Ok, so 2 things...

1. Did you check the build output folder for the tinyxml project? the library will end with .lib so there won't be that many options :)
2. Have you made sure the linker knows where to look for the library? If you've not told it where to look then even if the library is called tinyxml.lib it won't find it.

NB. Looking at the list of projects (from the above jpg), it could also be called tinyxml_lib.lib -- but if you check the output folder for when you built tinyxml it should be pretty obvious.
evilrixSenior Software Engineer (Avast)

Commented:
Anyway... I'm off to bed now (I've got a 05:30hrs start) so I'll leave you in Alex' capable hands.

Night.

Author

Commented:
it is tinyxmld.lib for sure. I checked the c: through cmd
I will trying changing the folder for the linker to the "Debug" folder now..

Author

Commented:
Ok it was the debug folder.
Thanks eveilrx and alex.
>>>> Ok it was the debug folder.
>>>> Thanks eveilrx and alex.
I was involved in some other thread but it is good that you found the location ;-)

You probably should link against a Release version, as it hardly makes sense to debug tinyxml. It is good practice to copy the .lib file from Release folder to some central lib folder. You can use the Post-Build-Step (or Events) for that.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial