473,804 Members | 3,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Makefile for shared library

I'm not a Makefile expert. I have a real small program (just a
main.cpp) that needs to tie into an existing library. Now other
programs I've seen that use the library just do #include "Library.h"
but and that works. Of course that doesn't work for me because when I
do g++ main.cpp -o prog, it has no idea what to do with Library.h. I
take a look at the other people's make files and it's absolute voodoo
to me.

So is there an easy way to write my makefile to use that library? so
doing #include "Library.h" compiles? Thanks.
Feb 14 '08 #1
4 9019
On Feb 14, 1:02 pm, Travis <travis.bow...@ gmail.comwrote:
I'm not a Makefile expert. I have a real small program (just a
main.cpp) that needs to tie into an existing library. Now other
programs I've seen that use the library just do #include "Library.h"
but and that works. Of course that doesn't work for me because when I
do g++ main.cpp -o prog, it has no idea what to do with Library.h. I
take a look at the other people's make files and it's absolute voodoo
to me.

So is there an easy way to write my makefile to use that library? so
doing #include "Library.h" compiles? Thanks.
Also. I noticed that in the directory for the library that other
people wrote, there is a MyLibrary.a file. Is that all I need to tie
into? Not sure what the compile line is.
Feb 14 '08 #2
Travis wrote:
I'm not a Makefile expert. [..]
Makefiles are offtopic. See the -l (that's a lowercase L)
compilation switch for your compiler.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Feb 14 '08 #3
Okay. Sorry for not RTFM. I'm trying. And sorry for being off topic.

Cheers.
Feb 14 '08 #4
On Feb 14, 10:18 pm, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
Travis wrote:
I'm not a Makefile expert. [..]
Makefiles are offtopic. See the -l (that's a lowercase L)
compilation switch for your compiler.
That depends on the compiler. -l is traditionally the option
under Unix (where it also involves special naming conventions,
and other things), but I don't think it works with VC++.

Normally, a "component" will be delivered as a library and a set
of header files. You install it somewhere; you then have to
inform the compiler where to look for the headers (-I or /I are
frequently the option for this) and to use the library when it
links---specifying the full path to the library will generally
work. (Even under Unix, I find that I only use -l for system
libraries.)

You might also have to use different options according to
whether you want to link the library statically or not.

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Feb 15 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2201
by: Simon | last post by:
Hello. I wanna use my dynamic shared library(built with C language) with php script. (PHP version is 4.0.6) So I making a shared library(*.so) in Solaris environment(2.7) and it is successful. Php script can load my library successfully. And Now I port my library to HP(HP-UX 11.0) and IBM(AIX 4.1.3) system.
5
10534
by: Oliver | last post by:
Hi, I have a problem with a shared library of mine. I compile the *.o files and then generate the .so lib with: cc -shared libjava_vrpn.so *.o When I then run my program I get an error for an unresolved symbol. The symbols it's looking for are in another library called libvrpn.a, but for some unknown reason the compiler does not uses this library when I tell him to used.
6
3457
by: klh | last post by:
I have an old version of DB2 Connect (v 6) installed on a Sun Solaris (v 2.9)box. It has been installed for several years, and to me, it seems to work okay. However, an application that uses DB2 Connect is having problems. While looking through db2diag.log I noticed a lot of occurrences of the following message: 2004-06-29-23.23.38.432624 Instance:db2inst1 Node:000 PID:4387(uvsh) Appid: oper_system_services licLoadLib Probe:1
2
2043
by: santa19992000 | last post by:
Confusing th eword with "library", "shared library" and how to use these things in real C project, is there any small example I can take a look. Thanks.
7
3396
by: akennis | last post by:
First of all, sorry for duplicating this post. I put it up in the alt.comp.lang.learn.c-c++ mistakenly. I'm investigating a problem whereby exceptions thrown from functions in a Shared Library which was dynamically loaded (dlopen) are not properly caught by the caller. Specifically, when compiling with G++ version 4.0, the RTTI data associated with the exception types is not being properly aligned between the Shared Library and its...
5
475
by: David T. Ashley | last post by:
I've occasionally had trouble compiling and linking programs that use shared libraries. That never made a lot of sense to me, because I thought the operating system went hunting for the symbols and libraries at runtime (and not before). Questions: a)How do the development tools know that a given symbol (a function entry point, for example) is located in a shared library and won't be linked in statically?
3
3275
by: Bala | last post by:
Hello, I am trying to create a shared library on solaris. The inputs to this library is a source file and then 2 static libraries. I need to call code within the shared library in another application which in turn will use the static libraries for further processing. This is the command i am using to build the shared library
4
2716
by: Nethali | last post by:
Hi folks, Is there any way to embed shared library directly, to executable file it self so that executable file can run stand alone without the shared library. I don't want to compile the source, make the static library and plug it. I just want to use dynamic library as it is. Thanks in advance...
3
3233
by: S S | last post by:
Hi Are there some known issues using STL with shared library. Recently I got some crash for which the reason I dont see any, and searching on goolge shown some such issues with shared library. If somebody can help ? Thanks in advance. S
3
2334
by: amit2781 | last post by:
I am trying to build the my project on HPUX (HP-UX oscar B.11.11 U 9000/800 741028561 unlimited-user license) which access the Mysql library. But it is giving error as : Error : MySQL51/lib/hpux/libmysqld.a(client.o) - shared library must be position independent. Use +z or +Z to recompile. I am using this option in building: aCC -Wl,+s,-E,+vnocompatwarnings -z -g0 -b -Wl,-Bsymbolic. I also tried using the +Z, +z, also added...
0
9584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10583
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9160
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.