Programming :: Static Linking Versus Dynamic Linking
Apr 18, 2010
I have written an OpenGL based program which uses i.a. libjpeg that I want to link statically so I can send it to someone who doesn't have all the libraries needed installed to allow for a dynamically linked executable to run. As such I tried with giving the [b]-static[b] parameter to gcc.
Code:
x86_1$ make
gcc -O3 -c jpegloader.c
gcc --std=c99 -O3 -c --std=c99 -I/usr/include -L/usr/X11R6/lib main.c
[code].....
Why would gcc claim that I'm missing GLUT? This works perfectly fine when I do dynamic linking -- i.e. omitting the -static argument.
View 13 Replies
ADVERTISEMENT
Mar 16, 2010
I have a third party static library (libSTATIC.a) that I cannot recompile into a shared library. I want to create a shared library (libSHARED.so) that uses the C functions in the static library. Is it possible to do this? In other words, when linking a C program with gcc by using the -shared flag, is it necessary that all all libraries invoked in the program (even low level libraries such as libc for example) be available as shared libraries as well?
View 2 Replies
View Related
Jun 10, 2010
There's a problem with static linking (and no problems with dynamic linking).
Here's my code:
Quote:
And makefile rule:
Quote:
That's dynamic linking. And it works perfectly. If i use static linking
Quote:
There is an undefined reference error:
Quote:
As nm shows there's a symbol named BuzzerInit in static library.
View 2 Replies
View Related
Apr 13, 2011
I am creating two shared libs that i intend to be dynamically linkable in C and C++, cross platform Linux/Windows/Mac. As a basic sketch, true for both libs, the lib code is in several .c/.cpp and .h files. For now, I'll talk about the part that I am actively working on, a lib named Discover, i.e. libdiscover.so.1.0. First, everything is in a namespace, RemKon_Discover.
The main Discover.cpp defines the methods for the Discover class (declared in Discover.h) and has extern "C' routines that can return pointers to my main c++ object. The call to GetLibraryMainPointer() creates a Discover class object, theMainObject (ok, I win a prize for dumb names) and returns the (non-mangled) pointer to the caller over in my test program. The Discover class itself is declared extern "c" and the tester program #includes "Discover.h".
In the test program, dlopen() correctly opens the lib and dlsym() gets the pointer to theMainObject. However, when I use that pointer in the tester program to access a method (aDiscoverObject->hello(), e.g.) I get compile time errors saying that Discover::hello() in an undefined reference. My makefile is attached.
[Code]....
View 10 Replies
View Related
Jul 8, 2011
Why can't chroot command be used for dynamically linking objects?
View 1 Replies
View Related
Feb 23, 2011
I'm building a static library (openssl) and linking with a shared library. I built openssl static library with out -fPIC option and in the makefile of shared library there is an option of -fPIC. When I'm compiling shared library with static library, I'm not getting any relocatable error, since static library is not built with -fPIC and shared library is compiling with -fPIC.
GCC version : gcc 4.0.4
OS : CentOS 5.2
View 3 Replies
View Related
Apr 29, 2010
I have a C code and assembly (nasm) code and I am not able to find how to link them each other. Here are the codes :
NASM side:
Code:
global_maxofthree
section .text
_maxofthree:
[code]....
I am using ubuntu 9.10 and my NASM version 2.05.01 compiled on Nov 5 2008.
View 4 Replies
View Related
Apr 11, 2010
This is probably a really stupid thing to ask considering the development I'm doing (effectivly creating a virus scanner), but how do I link classes/cpp files?I have 3 applications/sections that I can compile/combine with a makefile, that's fine, but I need them to run 1, 2, 3 once the output from the makefile is done.Currently the only section to actually run is whichever I have "main" in and obviously if I put that into all three, they won't compile as one.I've been looking all over the place at all sorts, header files and such, but there is no mention of how toually do this although I'm sure it must be possible. I'm used to being able to do this in Java and I'm sure I've seen C++ applications do it, but not worked out how.I have 3x .cpp files which are combined into one using a makefile:
Code:
# Virus Scanner
scanner.out : ProgramList.o MD5Hash.o HazardCheck.o
[code]...
View 2 Replies
View Related
Dec 11, 2010
I am trying to build an application that must link with python so as to load a python module during runtime.I have this makefile :
Code:
[alex@iskandhar src]$ cat Makefile
CFLAGS = -Wall -O3 -I ../../../SPOOLES.2.2 -DARCH="Linux" -DSPOOLES -DARPACK
[code]....
View 4 Replies
View Related
Oct 5, 2010
I have a really simple program trying to use XInput2.h, which fails on linking
Code:
#include <X11/extensions/XInput2.h>
int main(){
Display *XSession = XOpenDisplay(NULL);
int OriginScreen = 0;
int pID = 7;
[Code]....
I'm at a loss about what to do. Replacing XIWarpPointer by XWarpPointer and removing the pID argument solves it, but is not an option (no input ID).
View 5 Replies
View Related
May 27, 2010
I am trying to add some function to the c++ project (calling function) and the called function are in C. And i am getting error "undefined reference to "Hello(int,int)" " while linking. It is compiling correctly. It is linking to header file mention in the calling function. This header file has definition to the c - called function. Do you thinking having c files into C++ project will be a problem? Should I remove <stdio.h> in c files?
View 2 Replies
View Related
Oct 28, 2010
I have a question about shared objects and when mapping and linking is established in the following code...Well more of a verification.
getsetx.c - shared object source code Code: unsigned long x = 0;
unsigned long getx(void)
{
return x;
}
[Code].....
Now its my understanding when I execute ./testit, getsetx.so will get mapped into its address space at start up and testit will link any functions as they are needed..
View 3 Replies
View Related
Mar 13, 2011
compiling and linking using gcc: What does a file name with a suffix '.a' represent? If I have multiple .c and .h files, how can I link them together? How can I create the .a file?
View 6 Replies
View Related
Jan 9, 2011
I tried to link my executable program with 2 static libraries using g++. The 2 static libraries have the same function name. I'm expecting a "multiple definition" linking error from the linker, but I did not received.
Code:
//staticLibA.h
#ifndef _STATIC_LIBA_HEADER
#define _STATIC_LIBA_HEADER
int hello(void);
[code]....
View 4 Replies
View Related
Jan 22, 2011
I have set up Eclipse + CDT on an Arch 2010.05 install. I set up an eclipse project and added SDL as a dependency (see below):
Project -> Properties
* -> GCC C++ Compiler -> Preprocessor -> main=SDL_main
* -> GCC C++ Linker -> Libraries -> SDLmain SDL (in that order top to bottom)
* -> GCC C++ Linker -> Libraries -> Library Search Path -> /usr/lib/ (I verified that libSDL.a and libSDLmain.a are there)
This is the code I'm compiling. It's designed to just be a hello world style SDL app to see that everything is working.
[Code]...
View 3 Replies
View Related
May 6, 2010
[root@shankar-lx src1]# make
gcc -c main.c
gcc -c database.c
gcc -c e_sqlite.c
gcc -o TEST main.o database.o e_sqlite.o /usr/local/lib/libsqlite3.so.0.8.6 -w -lpthread
[root@shankar-lx src1]# ./TEST
./TEST: error while loading shared libraries: /usr/lib/libsqlite3.so.0: ELF file OS ABI invalid
My application compiled well but when try to run, it is giving ELF file OS ABI invalid ERROR. What is this error.
Kernel version is 2.4-18
View 1 Replies
View Related
Feb 10, 2011
I would like to ask you something about open-source and linux. Is it possible to make a commercial application for linux and sell it compiling it with linking to open-source libraries without altering them and consequently without allowing download of the source code and without making the application itself free?
View 3 Replies
View Related
Feb 17, 2010
I am using Centos 5.4 with gcc v4.1.2. If I take a bunch of .o files and I then link with my main.o to form an executable then this links and executes just fine. If however, I try to create an archive file (.a) using 'ar rus xxx.o yyy.o etc' and then try to link the resulting .a with my main.o then I get 'undefined symbol' linker errors and I don't understand why.
View 2 Replies
View Related
Dec 17, 2009
I have 3 c++ files, classdef.h (header file with class definition), methods.cpp (class methods) and program.cpp - the program itself. Both .cpp files have
Code:
#include "classdef.h"
in files. How I can link the files together and compile them in one executable program? I am using Geany IDE for coding.
View 4 Replies
View Related
Mar 24, 2010
The issue I am currently facing is more of an annoyance / curiosity, and it may not even be a problem, but it sure feels like one. Background: I am becoming a computational chemist (grad school begins in the fall) and the code I run is all in fortran. I am currently compiling with gfortran. When I compile the code (on a box running ubuntu server), everything appears to compile fine, but the linking stage is taking five to ten minutes. I ran the time command while making it and got the following results.
Quote:
time make
gfortran -c -O3 -fomit-frame-pointer -finline-functions -ffast-math suijtab.f
Linking testCompile ...
done
[code]...
I just don't understand why it is taking 5 minutes of real time if it only takes 10 - 15 sec of system time?
View 4 Replies
View Related
Mar 9, 2009
I have created a simple test class - Mortgage, with the class declaration in the .h file and the class's methods defined in the .cpp file. (mortgage.h && mortgage.cpp, respectively) Straight up C++ 101 as far as I can tell. I instantiate the class in the main() function, which is defined in practice.cpp. Using Geany on Ubuntu, both the practice.o and mortgage.o files are created, but then I get a linker error: undefined reference to class::functionName
I get it for each function. If the mortgage.cpp file is foremost in the editor when I click "build", then I get the undefined reference to main() error, if practice.cpp is foremost (where the main() function is) then I get undefined reference to Mortgage::Mortgage(), and all the rest of the functions defined for that class. How do I get the linker to know where my object files are so it will link them in? Or is the problem somewhere else entirely?
View 8 Replies
View Related
May 12, 2011
My project looks like this:
Home
The Team [no-page]
-X
-Y
-Z
Projects [no-page]
-Coding [no-page]
--A
--B
--C
-Desing [no-page]
--E
--F
-Security [no-page]
--G
--H
Note: the Code/Design/Security projects pages (A,B,C,D...) will be at start around 35 pages, and will grow. My index.php is something like this:
PHP Code: .....
What I would like to know is how to build the content (the home-main.php)? Do it dynamically based on a link something like this index.php?page=coding_b, and put in the index.php page a number of 35 if/else statements to cover all the project pages or ... static, creating every page for the projects menu when I create the menu? I check if a page 'pro-co-a.php' exists, if not I create it based on some template and do the query to get the content from db or? How to organize the pages, if using static page?
View 5 Replies
View Related
Sep 11, 2010
I am currently looking for tools for static/dynamic code analysis for embedded Linux system development (both device driver and user space apps). We will use Eclipse IDE and C++ lanuage. I hope the tools are easy-to-use, reliable, popular, better with good supports, and not-too-expensive. I already find a list of tools at WiKi, however, I don't have time to try them all. Could anyboy please recommend me a few? If you can tell me briefly about their pros and cons, that will be the bet.
View 1 Replies
View Related
Oct 1, 2009
I have created a Fedora 11 image with the GUI stripped out that autoboots into a mainframe terminal emulation program(c3270). I have everything working except for a print screen function. I have made a little script that will dump the screen from tty3 and send it to a printer, but I have no way for the end user to run this without giving them access to a terminal and I do not want them playing with that. So I was wondering if anyone knew a way to link the running of a script to a keybinding. That way all they have to do is hit Print Screen or some alt + key combo to get the screen capture.
View 2 Replies
View Related
Oct 25, 2010
I want to prevent grub-pc from automatically creating links to other operating systems on my laptop. Whenever there is a kernel update, grub.cfg ends with links pointing at my Windows 7 installation - I want to get rid of those links. At the moment I am doing that by manually editing the grub.cfg file and it has always worked that way. I tried to force grub-pc to avoid creating links to Windows by renaming the relevant scripts in /etc/grub.d edbarx@edbarx-pc2:/etc/grub.d$ ls 00_header 05_debian_theme 10_linux 20_linux_xen _30_os-prober _30_otheros 40_custom 41_custom README As you can see I added an underscore to the files that I don't want to be executed.
I think this can be solved by changing the file permissions of the unwanted scripts making them impossible to execute.
edbarx@edbarx-pc2:/etc/grub.d$ ls -l
total 52
-rwxr-xr-x 1 root root 6433 Aug 7 18:10 00_header
-rwxr-xr-x 1 root root 1474 Jul 16 18:46 05_debian_theme
-rwxr-xr-x 1 root root 4252 Aug 7 18:10 10_linux
[Code]....
View 11 Replies
View Related
Apr 1, 2011
We have one office with a simple samba server running on Lenny; not a PDC, just simple username/password authentication. It also acts as a DHCP server, NTP server, and DNS server. All clients are windows machines (mainly XP Pro, but also starting to get Win7 show up). For remote access, most users have chrooted WinSCP; OpenVPN was setup, but too slow for most AutoCAD uses (our primary application). It is still used by a few people, though.
I need to set up a similar system in another location, and need to provide access to both servers. People mainly access files stored in their own office, but will occasionally need to access files in the other office. In intend on having both run the same version, whether I stick with Lenny or put both on Squeeze.
I was thinking of setting up both servers, and then mounting the remote file system (the "other" server) over the internet, possibly via sshfs, but do not know if it is reliable enough. Or perhaps via OpenVPN connecting the servers, but then the overhead of the VPN may become an issue, adding lag time. The remote shares would then be accessible via the samba config.
Are there other options that may be easier to set up, more reliable, or more secure? We do not want a domain set up, just simple workgroups. Since many are using their personal laptops, joining them to the domain can cause some problems. It would also require more effort to add a new computer, and with the constant stream of outside consultants we use, that could get cumbersome.
My main issue: no budget beyond the low cost box for the second file server, so it has to be an open source solution from start to finish.
I'm not quite a newbie - I have quite a bit of experience setting up and maintaining basic Samba / DHCP / ssh servers - but not much beyond those. I certainly am open to learning new things and doing the research, but my head is swimming with all the options I have come across.
View 1 Replies
View Related
Oct 17, 2010
I am running Fedora 13 on a ASUS G71G Trying to install GTK+ 2.4.8; after installing all the dependencies(Pango, Glib2.0, ATK), I ran ./configure from my GTK+ directory. It configured for a while, then this happened: checking for X... no configure: error: X development libraries not found I tried linking them with PKG_CONFIG_PATH=<path to X lib directory>, but I got the same error message. How do I get GTK+ to recognize the X development libraries? Additionally, does the default build of X11 on Fedora 13 contain the appropriate libraries? Ive included the GTK+ configure scripts as an attachment.
View 1 Replies
View Related
Mar 18, 2010
I have a domain name registered with Enom and have access to the domain settings, what I want to know is there a way I can link my domain name (sbarow.com) to my Ubuntu server. I would like to be able to type my [url] into my browser as opposed to [url] to access my server from other locations.
View 4 Replies
View Related
May 13, 2010
i would like to link a folder, in my case that is 'Pictures' to a different harddrive with a folder containing pictures.So whenever i save pictures it would save by default onto the harddrive with the linked folder.How can i do that. I tried to do it with ls i think but this makes softlinks which did not let me open automatically open the other folder. omg i hope i don't make it to complicated to understand.So here a visual plan of it.the default folder/home/user/pictureslike to link it to /media/pictures/photoshotsso this is the harddrive (another internal harddrive) which contains a different folder where i store my photos in general.
View 9 Replies
View Related
Jan 4, 2011
What issues will I create for myself if I link /bin/sh back to bash?
View 3 Replies
View Related