Gcc Compiler Error Undefined Reference To
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might undefined reference to function in c have Meta Discuss the workings and policies of this site About
Undefined Reference To Gcc
Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads
Gcc Undefined Reference To Function
with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million
How To Solve Undefined Reference Error In C
programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Linker error on Linux: “undefined reference to” up vote 10 down vote favorite 1 I am able to make a shared library without problems. I create libcbitcoin.so (with no errors) and attempt to link against it with an executable as undefined reference to g++ well as OpenSSL libraries. I use this command: gcc -L/media/sf_BitEagle_Projects/cbitcoin/build/bin -lcbitcoin \ -Wl-rpath,/media/sf_BitEagle_Projects/cbitcoin/build/bin -lssl -lcrypto \ -L/usr/local/ssl/lib/ -o /media/sf_BitEagle_Projects/cbitcoin/build/bin/testCBAddress \ /media/sf_BitEagle_Projects/cbitcoin/build/obj/testCBAddress.o \ /media/sf_BitEagle_Projects/cbitcoin/build/obj/CBOpenSSLCrypto.o The bin directory is the location of the library. The obj directory has the object files I wish to link into an executable. In the command I use the -L, -l and -rpath options which I thought was all that is needed for linking in linux. It seems I am wrong since I get errors like: /media/sf_BitEagle_Projects/cbitcoin/test/testCBAddress.c:40: undefined reference to `CBNewByteArrayFromString' CBNewByteArrayFromString is found in the library. For some reason it is not being linked. OpenSSL too: /media/sf_BitEagle_Projects/cbitcoin/dependencies/crypto/CBOpenSSLCrypto.c:37: undefined reference to `SHA1' How do I get the linking to work? GCC version: gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 On Linux Mint 13 Thank you. linux gcc build linker share|improve this question edited Sep 5 '12 at 0:19 choroba 106k1089146 asked Sep 5 '12 at 0:01 Matthew Mitchell 1,48764789 Are you sure you want to hard-wire the /media/sf_BitEagle_Projects/cbitcoin/build/bin path into your executab
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack undefined reference to a function c++ Overflow the company Business Learn more about hiring developers or posting ads with us Stack c undefined reference to function in header file Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community c undefined reference to pthread_create of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up gcc: undefined reference to up vote 17 down vote favorite 2 I would like to compile this. http://stackoverflow.com/questions/12272864/linker-error-on-linux-undefined-reference-to program.c #include
Get Kubuntu Get Xubuntu Get Lubuntu Get UbuntuStudio Get Mythbuntu Get Edubuntu Get Ubuntu-GNOME Get UbuntuKylin Ubuntu Code of Conduct Ubuntu Wiki Community Wiki https://ubuntuforums.org/showthread.php?t=1687827 Other Support Launchpad Answers Ubuntu IRC Support AskUbuntu Official Documentation User Documentation https://latedev.wordpress.com/2014/04/22/common-c-error-messages-2-unresolved-reference/ Social Media Facebook Twitter Useful Links Distrowatch Bugs: Ubuntu PPAs: Ubuntu Web Upd8: Ubuntu OMG! Ubuntu Ubuntu Insights Planet Ubuntu Activity Page Please read before SSO login Advanced Search Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] compiling with gcc and "undefined reference undefined reference to xxx" Having an Issue With Posting ? Do you want to help us debug the posting issues ? < is the place to report it, thanks ! Results 1 to 4 of 4 Thread: compiling with gcc and "undefined reference to xxx" Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to undefined reference to Threaded Mode February 14th, 2011 #1 NeillHog View Profile View Forum Posts Private Message Visit Homepage Gee! These Aren't Roasted! Join Date Jul 2007 Location The Bavarian Alps Beans 129 DistroKubuntu 7.10 Gutsy Gibbon compiling with gcc and "undefined reference to xxx" I have run up against a wall. I really appreciate any and all help because I am so out of my depth. I have installed gcc on a NSLU2. Running gcc -o test test.c brings no error and afterwards I can run the program test with ./test. test.c #include
error message (or “unresolved external symbol, for Visual C++ users). This is not actually a message from the compiler, but is emitted by the linker, so the first thing to do is to understand what the linker is, and what it does. Linker 101 To understand the linker, you have to understand how C++ programs are built. For all but the very simplest programs, the program is composed of multiple C++ source files (also known as “translation units”). These are compiled separately, using the C++ compiler, to produce object code files (files with a .o or a .obj extension) which contain machine code. Each object code file knows nothing about the others, so if you call a function from one object file that exists in another, the compiler cannot provide the address of the called function. This is where the the linker comes in. Once all the object files have been produced, the linker looks at them and works out what the final addresses of functions in the executable will be. It then patches up the addresses the compiler could not provide. It does the same for any libraries (.a and .lib files) you may be using. And finally it writes the executable file out to disk. The linker is normally a separate program from the compiler (for example, the GCC linker is called ld) but will normally be called for you when you use your compiler suite’s driver program (so the GCC driver g++ will call ld for you). Traditionally, linker technology has lagged behind compilers, mostly because it’s generally more fun to build a compiler than to build a linker. And linkers do not necessarily have access to the source code for the object files they are linking. Put together, you get a situation where linker errors, and the reasons for them, can be cryptic in the extreme. Undefined reference Put simply, the “undefined reference” error means you have a reference (nothing to do with the C++ reference type) to a name (function, variable, constant etc.) in your program that the linker cannot find a definition for when it looks through all the object files and libraries that make up your project. There are any number of reasons why it can’t find the definition – we’ll look at the commonest ones now. No Definition Probably the most common reason for unresolved reference errors is that you simply have not defined the thing you are referencing. This code illustrates the problem: int foo(); int main() { foo(); } Here, we have a declaration of the function foo(), which we call in main(), but no definition. So we get the error (slightly edited for clarity): a.cpp:(.text+0xc): undefined reference to `foo()' error: ld returned