Link .lib

This is a discussion on Link .lib within the Windows Programming forums, part of the Platform Specific Boards category; How can I link .lib (static not dll) with my project? (VC 6.0) I don't want to insert another project ...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    24

    Link .lib

    How can I link .lib (static not dll) with my project? (VC 6.0)
    I don't want to insert another project into workspace.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    In the linker settings, you add
    - the path to where the library is located (if it's not there already)
    - the name of the library to be linked
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    24
    Tnx,
    but can I also do this without changing project settings - in code?

    Code:
    #pragma comment(lib, "./API/mylib.lib")
    ???

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    If you would like to sacrafice portability, then you may.

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    24
    Quote Originally Posted by Tonto
    If you would like to sacrafice portability, then you may.
    Portability? Between different VC versions?

  6. #6
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    No, between different platforms.
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  7. #7
    Registered User
    Join Date
    Jun 2005
    Posts
    24
    Now I'm confused...
    It works with Win XP, 2K, 98.
    Did you mean non-windows platforms?

  8. #8
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Likely it won't work for me, and I'm on Windows 98. #pragma is compiler dependant. Someone on a Mac/Linux box definately won't be using VC, and even some Windows users (like me) aren't. (MinGW/gcc)
    What's so wrong with putting it in the project options? Besides, what source file would you locate a #pragma in? One or all? If you later want to change that #pragma, you then either have to hunt for one source file, if you're not familiar with the project, or change several. And when linking, it seems it'll be less obvious what's getting linked than if you specify somewhere centralized, like project options or a makefile.
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  9. #9
    Registered User
    Join Date
    Jun 2005
    Posts
    24
    I'm using anyway MFC, so the portability... "is not a problem"

    I tried to change the link settings, but I'm doing something wrong, because it wont work, linker gives errors (LNK2001 - unresolved external symbol). But it works with #pragma... thats the reason why I use it
    Last edited by fiff; 12-28-2006 at 03:50 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linked List, Please Help!
    By CodeMonkeyZ in forum C Programming
    Replies: 5
    Last Post: 02-17-2009, 06:23 AM
  2. I'm confused about link lists (again)
    By JFonseka in forum C Programming
    Replies: 4
    Last Post: 06-13-2008, 09:13 PM
  3. possible to link and run with .lib file without .dll file?
    By George2 in forum Windows Programming
    Replies: 1
    Last Post: 05-25-2006, 10:05 PM
  4. Function to check memory left from malloc and free?
    By Lechx in forum C Programming
    Replies: 4
    Last Post: 04-24-2006, 06:45 AM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM

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