Gcc Link Error
Contents |
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 gcc undefined reference to function more about Stack Overflow the company Business Learn more about hiring developers or posting
Gcc Linker Undefined Reference
ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack undefined reference to c Overflow is a community of 4.7 million 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 ld undefined reference to function 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 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
Gcc Undefined Reference To Sqrt
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 executable? –Jonathan Leffler Sep 5 '12 at 0:07 Here I'm just linking a test. It's designed to be run to test the library so it doesn't matter as long as it works after it has been built. –Matthew Mitchell Sep 5 '12 at 0:13 OK — you're sure; that's fine. –Jonathan Leffler Sep 5 '12 at 0:17 possible duplicate of Trying to include a library, but keep getting 'undefined reference to' messages –Victor
communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start 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 Overflow the company Business c undefined reference to function in header file Learn more about hiring developers or posting ads with us Ask Ubuntu Questions Tags Users undefined reference c++ Badges Unanswered Ask Question _ Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes
Linking Undefined Reference To
a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Why do I get “undefined reference” errors when linking against OpenSSL? http://stackoverflow.com/questions/12272864/linker-error-on-linux-undefined-reference-to up vote 4 down vote favorite 1 My compilation process throws around errors like ..undefined reference to `BN_cmp' although I include
Today's Posts Advanced Search Find the answer to your Linux question: Entire Site Articles Downloads Forums Linux Hosting Forum GNU Linux Zone Programming / Scripting Can't solve gcc linking error, please help. If this is http://www.linuxforums.org/forum/programming-scripting/201891-cant-solve-gcc-linking-error-please-help.html your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the https://latedev.wordpress.com/2014/04/22/common-c-error-messages-2-unresolved-reference/ forum that you want to visit from the selection below. ** If you are logged in, most ads will not be displayed. ** Linuxforums now supports the Tapatalk app for your mobile device. Results 1 to undefined reference 10 of 10 Thread: Can't solve gcc linking error, please help. Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Enjoy an ad free experience by logging in. Not a member yet? Register. 06-23-2014 #1 b2rdark View Profile View Forum Posts Private Message View Articles Just Joined! Join Date Jun 2014 Posts 4 Can't solve gcc linking error, please help. undefined reference to Hi! I'm trying to compile a very simple code which uses functions defined in the Linux PCI Utilities library, but the linker stops with "undefined reference to" errors and im running out of ideas. I'm on ubuntu 14.04 LTS (64-bit) and i've installed the libpci-dev (1:3.2.1-1ubuntu5) package too. Here is my test.c: Code: #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