Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how i can link c library from c++ class

how i can link c library from c++ class

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rajesh match
    wrote on last edited by
    #1

    i have C library which i need to invoke from c++ class but when i tried to invoke the functions of the c library i am getting linker error of particlar function Can anybody help thanx

    T 1 Reply Last reply
    0
    • R Rajesh match

      i have C library which i need to invoke from c++ class but when i tried to invoke the functions of the c library i am getting linker error of particlar function Can anybody help thanx

      T Offline
      T Offline
      Taka Muraoka
      wrote on last edited by
      #2

      When you declare the function, wrap it in an extern "C": extern "C" { extern void the_c_function() ; }


      Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin Awasu 1.1.5 [^]: A free RSS reader with support for Code Project.

      R 1 Reply Last reply
      0
      • T Taka Muraoka

        When you declare the function, wrap it in an extern "C": extern "C" { extern void the_c_function() ; }


        Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin Awasu 1.1.5 [^]: A free RSS reader with support for Code Project.

        R Offline
        R Offline
        Rajesh match
        wrote on last edited by
        #3

        Thanx for reply This should be in library or in my class if so i don't have c library source code then how can modify it thax..

        T 1 Reply Last reply
        0
        • R Rajesh match

          Thanx for reply This should be in library or in my class if so i don't have c library source code then how can modify it thax..

          T Offline
          T Offline
          Taka Muraoka
          wrote on last edited by
          #4

          Wrap the header file: extern "C" { #include "api.h" } Or just duplicate the declarations you want. If you're writing a C library, it's good form to put the extern "C" *inside* the header file but not every one does it.


          Lets be honest, isn't it amazing how many truly stupid people you meet during the course of the day. Carry around a pad and pencil, you'll have twenty or thirty names by the end of the day - George Carlin Awasu 1.1.5 [^]: A free RSS reader with support for Code Project.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups