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. linker error for extern function

linker error for extern function

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
5 Posts 3 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    hai, I'm working in vc++ win32. I'm using two files..say file1.cpp and file2.cpp. In file1 I'm defining a function and want to call in file2. ie I'm doing as //file1.cpp// int myfunc(); . . . int myfunc() { .... } //file2.cpp// #include file1.h extern int myfunc(); .... int func2() { int xxx = myfunc(); } If I do like this it is giving LNK2019: unresolved external symbol_myfunc referenced in func2 fatal error LNK1120: 1 unresolved externals Where did I went wrong.. Thanks in advance..

    B B 2 Replies Last reply
    0
    • L Lost User

      hai, I'm working in vc++ win32. I'm using two files..say file1.cpp and file2.cpp. In file1 I'm defining a function and want to call in file2. ie I'm doing as //file1.cpp// int myfunc(); . . . int myfunc() { .... } //file2.cpp// #include file1.h extern int myfunc(); .... int func2() { int xxx = myfunc(); } If I do like this it is giving LNK2019: unresolved external symbol_myfunc referenced in func2 fatal error LNK1120: 1 unresolved externals Where did I went wrong.. Thanks in advance..

      B Offline
      B Offline
      bryce
      wrote on last edited by
      #2

      do you have the second cpp added to your project? bryce --- To paraphrase Fred Dagg - the views expressed in this post are bloody good ones. --
      Publitor, making Pubmed easy. http://www.sohocode.com/publitor

      Our kids book :The Snot Goblin

      L 1 Reply Last reply
      0
      • B bryce

        do you have the second cpp added to your project? bryce --- To paraphrase Fred Dagg - the views expressed in this post are bloody good ones. --
        Publitor, making Pubmed easy. http://www.sohocode.com/publitor

        Our kids book :The Snot Goblin

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Yes..I it is added to the project..

        B 1 Reply Last reply
        0
        • L Lost User

          Yes..I it is added to the project..

          B Offline
          B Offline
          bryce
          wrote on last edited by
          #4

          email it to me and i'll take a quick look (no promises) if you havnt got it sorted bryce --- To paraphrase Fred Dagg - the views expressed in this post are bloody good ones. --
          Publitor, making Pubmed easy. http://www.sohocode.com/publitor

          Our kids book :The Snot Goblin

          1 Reply Last reply
          0
          • L Lost User

            hai, I'm working in vc++ win32. I'm using two files..say file1.cpp and file2.cpp. In file1 I'm defining a function and want to call in file2. ie I'm doing as //file1.cpp// int myfunc(); . . . int myfunc() { .... } //file2.cpp// #include file1.h extern int myfunc(); .... int func2() { int xxx = myfunc(); } If I do like this it is giving LNK2019: unresolved external symbol_myfunc referenced in func2 fatal error LNK1120: 1 unresolved externals Where did I went wrong.. Thanks in advance..

            B Offline
            B Offline
            bmzhao
            wrote on last edited by
            #5

            1.rebuild all. 2.check myfunc() in file1.cpp

            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