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

Linker error

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
6 Posts 5 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.
  • D Offline
    D Offline
    dellthinker
    wrote on last edited by
    #1

    Hi all, i've played with/search for a solution and gotten frustrated over a problem that i have with a piece of code and i cant seem to get it down for some retarded reason. The error is this: error LNK2001: unresolved external symbol "int __cdecl brandom(int,int)" (?brandom@@YAHHH@Z) The code its talking about is #include #include "header.h" using namespace std; int dport = brandom(1900, 48000); int main(){ int dport = brandom(1900, 48000); cout << dport << endl; return 0; } #ifndef __RANDOM_H__ // Contents of header.h #define __RANDOM_H__ void init_random(); int brandom(int client,int top); int get_random_number(int range); #endif I've been to msdn about this stupid problem and yet i cant find out a way to resolve this. Can anyone help? Thanx in advance!

    J CPalliniC B 3 Replies Last reply
    0
    • D dellthinker

      Hi all, i've played with/search for a solution and gotten frustrated over a problem that i have with a piece of code and i cant seem to get it down for some retarded reason. The error is this: error LNK2001: unresolved external symbol "int __cdecl brandom(int,int)" (?brandom@@YAHHH@Z) The code its talking about is #include #include "header.h" using namespace std; int dport = brandom(1900, 48000); int main(){ int dport = brandom(1900, 48000); cout << dport << endl; return 0; } #ifndef __RANDOM_H__ // Contents of header.h #define __RANDOM_H__ void init_random(); int brandom(int client,int top); int get_random_number(int range); #endif I've been to msdn about this stupid problem and yet i cant find out a way to resolve this. Can anyone help? Thanx in advance!

      J Offline
      J Offline
      Joan M
      wrote on last edited by
      #2

      Could it be that __RANDOM_H__ would have been defined before? Hope this helps.

      https://www.robotecnik.com freelance robots, PLC and CNC programmer.

      B 1 Reply Last reply
      0
      • D dellthinker

        Hi all, i've played with/search for a solution and gotten frustrated over a problem that i have with a piece of code and i cant seem to get it down for some retarded reason. The error is this: error LNK2001: unresolved external symbol "int __cdecl brandom(int,int)" (?brandom@@YAHHH@Z) The code its talking about is #include #include "header.h" using namespace std; int dport = brandom(1900, 48000); int main(){ int dport = brandom(1900, 48000); cout << dport << endl; return 0; } #ifndef __RANDOM_H__ // Contents of header.h #define __RANDOM_H__ void init_random(); int brandom(int client,int top); int get_random_number(int range); #endif I've been to msdn about this stupid problem and yet i cant find out a way to resolve this. Can anyone help? Thanx in advance!

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        The error message is clear: You have to link with the object (or the library) file containing the brandom function. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        [my articles]

        In testa che avete, signor di Ceprano?

        1 Reply Last reply
        0
        • J Joan M

          Could it be that __RANDOM_H__ would have been defined before? Hope this helps.

          B Offline
          B Offline
          Bram van Kampen
          wrote on last edited by
          #4

          Nope If it was defined before, the header would have been skipped in the build of the relevant obj, and created a list of undefined symbol errors Regards,

          Bram van Kampen

          J 1 Reply Last reply
          0
          • B Bram van Kampen

            Nope If it was defined before, the header would have been skipped in the build of the relevant obj, and created a list of undefined symbol errors Regards,

            Bram van Kampen

            J Offline
            J Offline
            Joan M
            wrote on last edited by
            #5

            ? If what he has written down is correct the only function that he is trying to use from that header file is the brandom one and precisely he is getting an unresolved external... Here I'm at 3:00 AM so I'm very tired, but it seems clear to me... EDIT: even if it is so late this is not excuse for not saying hello at the beginning and best regards at the end... sorry... :~

            https://www.robotecnik.com freelance robots, PLC and CNC programmer.

            1 Reply Last reply
            0
            • D dellthinker

              Hi all, i've played with/search for a solution and gotten frustrated over a problem that i have with a piece of code and i cant seem to get it down for some retarded reason. The error is this: error LNK2001: unresolved external symbol "int __cdecl brandom(int,int)" (?brandom@@YAHHH@Z) The code its talking about is #include #include "header.h" using namespace std; int dport = brandom(1900, 48000); int main(){ int dport = brandom(1900, 48000); cout << dport << endl; return 0; } #ifndef __RANDOM_H__ // Contents of header.h #define __RANDOM_H__ void init_random(); int brandom(int client,int top); int get_random_number(int range); #endif I've been to msdn about this stupid problem and yet i cant find out a way to resolve this. Can anyone help? Thanx in advance!

              B Offline
              B Offline
              bob16972
              wrote on last edited by
              #6

              There are plenty of things that could be going wrong here, but my first guess is your missing a reference to a library. If your function is from a .dll, and you have a .lib file for it, you can avoid path problems by putting them in your project directory along with the header file and include the appropriate pragma. If that eliminates the problem, then you know you had path issues and you can move the .lib file, .dll, and .h file to where you want, each time updating your path settings. #include "SomeLibrary.h" #pragma comment(lib, "SomeLibrary.lib")

              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