Thread: Linking objects internally

  1. #1
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401

    Linking objects internally

    Is the following pre-processor code portable between different compilers, and/or does it comply with the C++ standard:

    Code:
    #pragma comment(lib,"somelib.lib")
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Pragmas are machine- or operating-system-specific by definition, and are usually different for every compiler.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    So to ensure, through the source code, that a certain library is linked, I should probably use LoadLibrary() on a DLL?
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Yeah I guess you could do that. Although I usually just link ( in the project settings ) to the import library and then include the necessary DLL header and I'm all set.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking with two objects
    By emanresu in forum C Programming
    Replies: 2
    Last Post: 11-07-2006, 07:42 AM
  2. Replies: 60
    Last Post: 12-20-2005, 11:36 PM
  3. Linking objects to your C++ projects
    By Dwizard in forum Windows Programming
    Replies: 5
    Last Post: 09-24-2005, 07:11 PM
  4. chain of objects within pop framework help needed
    By Davey in forum C++ Programming
    Replies: 0
    Last Post: 04-15-2004, 10:01 AM
  5. linking objects
    By doleman19 in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2001, 12:37 PM