Linking to shlwapi.lib in C, MSVC CMD.

This is a discussion on Linking to shlwapi.lib in C, MSVC CMD. within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I have a C code that uses some of the exports of shlwapi.dll and I'm trying to compile it ...

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    3

    Linking to shlwapi.lib in C, MSVC CMD.

    Hi, I have a C code that uses some of the exports of shlwapi.dll and I'm trying to compile it using Visual Studio 2008 and the Vista SDK.

    The problem is that when I compile it as C code I can't link to shlwapi.lib. I get the following error:

    Code:
    inicontrol.c
    shlwapi.lib
    c1 : fatal error C1083: Cannot open source file: 'shlwapi.lib': No such file or directory
    Generating Code...
    The command line to that is: cl /O1 /TC inicontrol.c shlwapi.lib

    Anyone knows if it's possible to compile it as C code and link to that library?

    Thanks in advance.

    P.S.: Linking as C++ code works well. Pointing to shlwapi.lib directly outputs loads of errors.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Did you add the path properly in your VS settings? You should have "/LIBPATH:some_path" where some_path is the path to the .lib file.
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #3
    Registered User
    Join Date
    Aug 2009
    Posts
    3
    Yes. Somewhat if it is compiled as C++ code it compiles just fine, but if it's compiled as C code the linker complains about finding the file.

    I've tried to point it to shlwapi.lib using the full path of to it, and it shows lots of errors:

    Code:
    inicontrol.c
    shlwapi.lib
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(1) : error C2059:
    syntax error : '!'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(2) : error C2018:
    unknown character '0x60'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(3) : error C2018:
    unknown character '0x2'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(3) : error C2018:
    unknown character '0x14'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(3) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(3) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(3) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(3) : error C2018:
    unknown character '0xe'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(3) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(3) : error C2018:
    unknown character '0xe'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(3) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(3) : error C2018:
    unknown character '0xe'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(4) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(4) : error C2018:
    unknown character '0xe'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C3872:
    '0xa0': this character is not allowed in an identifier
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C3872:
    '0xa0': this character is not allowed in an identifier
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1c'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1c'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1d'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1d'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x11'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x11'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x14'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x40'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x14'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x40'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x12'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x12'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x13'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x13'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(5) : error C2014:
    preprocessor command must start as first nonwhite space
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(6) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1c'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1c'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1d'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1d'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1e'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0xe'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1e'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0xe'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1e'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1e'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1b'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1b'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1b'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1b'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x8'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x8'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C2018:
    unknown character '0x1'
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : error C3872:
    '0x24': this character is not allowed in an identifier
    C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\shlwapi.lib(7) : fatal error C
    1003: error count exceeds 100; stopping compilation
    Generating Code...

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,246
    Unless I'm mistaken, it looks like you are trying to compile the .lib file instead of linking to it.
    bit∙hub [bit-huhb] n. A source and destination for information.

  5. #5
    Registered User
    Join Date
    Aug 2009
    Posts
    3
    Yes! That was the problem, I forgot the /link parameter.

    Thanks for your time and your help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trouble with MSVC, Mingw32 and Code::Blocks
    By Brafil in forum C Programming
    Replies: 11
    Last Post: 10-12-2009, 11:34 AM
  2. Problems linking with g++
    By Just in forum Linux Programming
    Replies: 11
    Last Post: 07-24-2006, 01:35 AM
  3. Linking error with DirectDrawCreateEx
    By jjj93421 in forum Game Programming
    Replies: 6
    Last Post: 04-06-2004, 03:57 PM
  4. GCC (cygwin) much faster than MSVC, Borland?
    By Sargnagel in forum C Programming
    Replies: 15
    Last Post: 08-05-2003, 03:15 AM
  5. help with allegro - linking errors
    By MadHatter in forum C++ Programming
    Replies: 1
    Last Post: 11-22-2002, 01:01 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21