CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 30
  1. #1
    Join Date
    Aug 2014
    Posts
    16

    [RESOLVED] LNK errors

    Hi all,

    I am relatively new to programming. I am trying to program using Visual studio 2005. The following is the code

    #include <stdio.h>
    #include <conio.h>

    #include "dynamixel.h"
    #pragma comment(lib,"dynamixel.lib")
    #define DEFAULT_PORTNUM 5
    #define DEFAULT_BAUDNUM 1

    void main()
    {
    dxl_initialize(DEFAULT_PORTNUM,DEFAULT_BAUDNUM);
    }
    I have added the Environment variables and set up the VC++ directories for include and library files. I am getting the following error:

    1>------ Build started: Project: Test1, Configuration: Debug Win32 ------
    1>Compiling...
    1>test source.cpp
    1>Linking...
    1>test source.obj : error LNK2019: unresolved external symbol _dxl_initialize@8 referenced in function _main
    1>C:\Users\Rambo\Documents\Visual Studio 2005\Projects\Test1\Debug\Test1.exe : fatal error LNK1120: 1 unresolved externals
    1>Build log was saved at "file://c:\Users\Muqeet\Documents\Visual Studio 2005\Projects\Test1\Test1\Debug\BuildLog.htm"
    1>Test1 - 2 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    I am only having source file. Any solution is greatly appreciated.

  2. #2
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: LNK errors

    the error should be obvious
    you are calling a function in main() called dxl_initialize
    and none of the libraries that are being linked have a function called that way.
    So you get an error telling you the linker can't find the function anywhere

    you'll need to figure out in what library that function resides
    then make the necessary changes to make sure the library/object file that contains that function is being linked as well.

  3. #3
    Join Date
    Aug 2014
    Posts
    16

    Re: LNK errors

    Hi OReubens,

    Thank you for answering my question.

    The library where this function resides is dynamixel.lib. When i type the function dxl_initialize it automatically it gives the syntax for it. So if it is not linked, it should not be showing the syntax right?

  4. #4
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: LNK errors

    Quote Originally Posted by learnforlife View Post
    Hi OReubens,

    Thank you for answering my question.

    The library where this function resides is dynamixel.lib. When i type the function dxl_initialize it automatically it gives the syntax for it. So if it is not linked, it should not be showing the syntax right?
    No. The syntax comes from the .h file not the .lib file. .h files are used for compiling, .lib files for linking. If the error is a link error then the problem is with the .lib files used.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  5. #5
    Join Date
    Aug 2014
    Posts
    16

    Re: LNK errors

    Quote Originally Posted by 2kaud View Post
    No. The syntax comes from the .h file not the .lib file. .h files are used for compiling, .lib files for linking. If the error is a link error then the problem is with the .lib files used.
    Hi kaud

    Thank you for replying.

    So the problem is with the code -#pragma comment(lib,"dynamixel.lib")
    I have the project file of the library. How do you think I can fix this issue?

  6. #6
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: LNK errors

    In which folder does the .lib file reside? Have you configured the project to use this folder for .lib files?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  7. #7
    Join Date
    Aug 2014
    Posts
    16

    Re: LNK errors

    The .lib file resides in the import folder, object file library. I have added the include and library folder in VC++ directories in the project and solutions.The object file library is stored in that folder called import i.e. C:\Dynamixel\import. I have added this folder in the library and include directories.

  8. #8
    Join Date
    Aug 2014
    Posts
    16

    Re: LNK errors

    Also, is it possible to add this library in the project and use it locally?

    Like add Dynamixel.lib on the Module of the Link tap's input in project characteristics?
    Last edited by learnforlife; August 22nd, 2014 at 11:58 AM.

  9. #9
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: LNK errors

    What does dumpbin.exe show for the dynamixel.lib file. See http://msdn.microsoft.com/en-us/library/c1h23y6c.aspx
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  10. #10
    Join Date
    Aug 2014
    Posts
    16

    Re: LNK errors

    Do you think that this is a problem of Windows 8.1? This library was released in the time of Windows xp.

  11. #11
    Join Date
    Aug 2014
    Posts
    16

    Re: LNK errors

    Quote Originally Posted by 2kaud View Post
    What does dumpbin.exe show for the dynamixel.lib file. See http://msdn.microsoft.com/en-us/library/c1h23y6c.aspx
    Thank you for helping me. Please find the info below.

    C:\Program Files (x86)\Microsoft Visual Studio 8\vc\bin>"C:\Program Files (x86)\
    Microsoft Visual Studio 8\Common7\Tools\vsvars32.bat"
    Setting environment for using Microsoft Visual Studio 2005 x86 tools.

    C:\Program Files (x86)\Microsoft Visual Studio 8\vc\bin>dir
    Volume in drive C is Windows8_OS
    Volume Serial Number is 0406-07EB

    Directory of C:\Program Files (x86)\Microsoft Visual Studio 8\vc\bin

    08/21/2014 12:42 PM <DIR> .
    08/21/2014 12:42 PM <DIR> ..
    08/21/2014 12:42 PM <DIR> 1033
    09/22/2005 11:49 PM 360,448 atlprov.dll
    09/23/2005 06:56 AM 69,312 bscmake.exe
    09/23/2005 12:12 AM 626,688 c1.dll
    09/23/2005 12:12 AM 2,277,376 c1xx.dll
    09/22/2005 11:52 PM 2,228,224 c2.dll
    09/23/2005 06:56 AM 117,432 cl.exe
    09/22/2005 11:52 PM 268 cl.exe.config
    09/23/2005 07:01 AM 142,016 clstencil.exe
    09/23/2005 06:56 AM 31,936 cvtres.exe
    09/23/2005 07:01 AM 14,528 dumpbin.exe
    09/23/2005 07:01 AM 14,528 editbin.exe
    09/23/2005 06:56 AM 14,008 lib.exe
    09/23/2005 06:56 AM 724,152 link.exe
    09/22/2005 11:22 PM 268 link.exe.config
    09/23/2005 07:56 AM 709,632 mt.exe
    09/23/2005 07:01 AM 82,616 nmake.exe
    09/23/2005 09:17 AM 30,720 rc.exe
    09/23/2005 09:17 AM 111,616 rcdll.dll
    09/22/2005 11:48 PM 892 SessionServices.sql
    09/23/2005 06:56 AM 189,120 sproxy.exe
    09/23/2005 07:01 AM 16,064 undname.exe
    09/23/2005 06:56 AM 69,824 vcdeploy.exe
    09/23/2005 09:20 AM 31 vcvars32.bat
    09/23/2005 07:01 AM 37,056 xdcmake.exe
    09/23/2005 12:36 AM 268 xdcmake.exe.config
    25 File(s) 7,869,023 bytes
    3 Dir(s) 408,561,381,376 bytes free

    C:\Program Files (x86)\Microsoft Visual Studio 8\vc\bin>dumpbin.exe
    Microsoft (R) COFF/PE Dumper Version 8.00.50727.42
    Copyright (C) Microsoft Corporation. All rights reserved.

    usage: DUMPBIN [options] [files]

    options:

    /ALL
    /ARCHIVEMEMBERS
    /CLRHEADER
    /DEPENDENTS
    /DIRECTIVES
    /DISASM[:{BYTES|NOBYTES}]
    /ERRORREPORT:{NONE|PROMPT|QUEUE|SEND}
    /EXPORTS
    /FPO
    /HEADERS
    /IMPORTS[:filename]
    /LINENUMBERS
    /LINKERMEMBER[:{1|2}]
    /LOADCONFIG
    /OUT:filename
    /PDATA
    /PDBPATH[:VERBOSE]
    /RANGE:vaMin[,vaMax]
    /RAWDATA[:{NONE|1|2|4|8}[,#]]
    /RELOCATIONS
    (press <return> to continue)
    /SECTION:name
    /SUMMARY
    /SYMBOLS
    /TLS
    /UNWINDINFO

    C:\Program Files (x86)\Microsoft Visual Studio 8\vc\bin>dumpbin dynamixel.lib
    Microsoft (R) COFF/PE Dumper Version 8.00.50727.42
    Copyright (C) Microsoft Corporation. All rights reserved.


    Dump of file dynamixel.lib
    DUMPBIN : fatal error LNK1181: cannot open input file 'dynamixel.lib'

    C:\Program Files (x86)\Microsoft Visual Studio 8\vc\bin>

  12. #12
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: LNK errors

    Dump of file dynamixel.lib
    DUMPBIN : fatal error LNK1181: cannot open input file 'dynamixel.lib'
    You'll probably need to specify the full path to the .lib file.

    Or have c:\program Files (X86)\Microsoft Visual Syudio 8\vc\bin as part of your environment path variable.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  13. #13
    Join Date
    Aug 2014
    Posts
    16

    Re: LNK errors

    I just pasted the dynamixel.lib file in c:\program Files (X86)\Microsoft Visual Syudio 8\vc\bin

    The following is the info from dumpbin.

    C:\Program Files (x86)\Microsoft Visual Studio 8\vc\bin>dir
    Volume in drive C is Windows8_OS
    Volume Serial Number is 0406-07EB

    Directory of C:\Program Files (x86)\Microsoft Visual Studio 8\vc\bin

    08/22/2014 01:48 PM <DIR> .
    08/22/2014 01:48 PM <DIR> ..
    08/21/2014 12:42 PM <DIR> 1033
    09/22/2005 11:49 PM 360,448 atlprov.dll
    09/23/2005 06:56 AM 69,312 bscmake.exe
    09/23/2005 12:12 AM 626,688 c1.dll
    09/23/2005 12:12 AM 2,277,376 c1xx.dll
    09/22/2005 11:52 PM 2,228,224 c2.dll
    09/23/2005 06:56 AM 117,432 cl.exe
    09/22/2005 11:52 PM 268 cl.exe.config
    09/23/2005 07:01 AM 142,016 clstencil.exe
    09/23/2005 06:56 AM 31,936 cvtres.exe
    09/23/2005 07:01 AM 14,528 dumpbin.exe
    07/08/2014 12:07 AM 6,010 dynamixel.lib
    09/23/2005 07:01 AM 14,528 editbin.exe
    09/23/2005 06:56 AM 14,008 lib.exe
    09/23/2005 06:56 AM 724,152 link.exe
    09/22/2005 11:22 PM 268 link.exe.config
    09/23/2005 07:56 AM 709,632 mt.exe
    09/23/2005 07:01 AM 82,616 nmake.exe
    09/23/2005 09:17 AM 30,720 rc.exe
    09/23/2005 09:17 AM 111,616 rcdll.dll
    09/22/2005 11:48 PM 892 SessionServices.sql
    09/23/2005 06:56 AM 189,120 sproxy.exe
    09/23/2005 07:01 AM 16,064 undname.exe
    09/23/2005 06:56 AM 69,824 vcdeploy.exe
    09/23/2005 09:20 AM 31 vcvars32.bat
    09/23/2005 07:01 AM 37,056 xdcmake.exe
    09/23/2005 12:36 AM 268 xdcmake.exe.config
    26 File(s) 7,875,033 bytes
    3 Dir(s) 408,537,989,120 bytes free

    C:\Program Files (x86)\Microsoft Visual Studio 8\vc\bin>dumpbin dynamixel.lib
    Microsoft (R) COFF/PE Dumper Version 8.00.50727.42
    Copyright (C) Microsoft Corporation. All rights reserved.


    Dump of file dynamixel.lib

    File Type: LIBRARY

    Summary

    CC .debug$S
    14 .idata$2
    14 .idata$3
    8 .idata$4
    8 .idata$5
    E .idata$6

    C:\Program Files (x86)\Microsoft Visual Studio 8\vc\bin>

  14. #14
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: LNK errors

    You need to specify the /exports option. See the link in post #9 for info.

    Try dumpbin dynamixel.lib /exports
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  15. #15
    Join Date
    Aug 2014
    Posts
    16

    Re: LNK errors

    Quote Originally Posted by 2kaud View Post
    You need to specify the /exports option. See the link in post #9 for info.

    Try dumpbin dynamixel.lib /exports
    I tried dumpbin dynamixel.lib/exports in command prompt. It gave the following error.

    C:\Program Files<x86>\Microsoft Visual Studio 8\vc\bin\dumpbin dynamixel.lib/exports
    Microsoft <R> COFF/PE Dumper Version 8.00.50727.42
    Copyright <C> Microsoft Corporation. All rights reserved.

    Dump of file dynamixel.lib/exports
    DUMPBIN : fatal error LNK1181: cannot open input file 'dynamixel.lib/exports'

Page 1 of 2 12 LastLast

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured