473,396 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Linking static library into a .o-file instead of the executable

13
Hello

I'm not sure this is the right place to ask, hope it's not too far off.

I'm using a big external library in my project, but need it only in one class. I'd like to link the library into the .o-file.

I realise this is not how .o-files normally work, but it would be handy to realize it in this case. I would then only have to link to my own .o-file in every executable I need it, and not search the library every time.

Hope someone can give me a hint :-)
Nov 21 '07 #1
3 1303
weaknessforcats
9,208 Expert Mod 8TB
The build process requires the linker to search libraries to resolve reference4s in the .o files. The linker needs to produce an output so there really is no way for it to just link into your .o file and keep it a .o file.

A couple of questions:

1) Why the issue in the first place?? So you have library used in only one class, all that means is the link step is a little longer. Most IDE tools have the libraries searched in the order of the path list to the libraries. You could oput your library at the end of the list so it would be searched only once since other .o references would be resolved before the linker got to your library.

2) Have you considered making your .o file a library?? That way you could resolve the references and provide the linker with an output format. Your users would use your header and add your library to their builds.
Nov 21 '07 #2
chroot
13
Thank you for the fast reply

1) Mostly I'm trying to make things tidier, as there are already a lot of libraries that I have to link every time. It would work just putting the library at the end of the path, just fells overdone. I was wondering if there's a better way.

2) Yes, that's about what I'm trying to do. A library would be good, but when I create a library, are the libraries it uses linked into it? I thought I'd have to use my new library, plus the ones I'm already linking.

Or does this depend on the operating system?
Nov 21 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
Yes, a library already has its libraries linked into it. Your memory footprint would increase.

Personally, I would opt for the big link and not worry about it.
Nov 21 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Peetah_junkmail | last post by:
Hi, I'm not sure this is completely a C related question since it's more about linking problems, so don't hesitate to redirect me to a more appropriate NG. I have a set of useful functions...
7
by: wmkew | last post by:
Hello everyone I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with...
6
by: Rudy Ray Moore | last post by:
I work with a multi-project workspace. One project (the "startup" project) has a "Configuration Type" of "Application (.exe)". The other 40 projects have a "Configuration Type" of "Static Library...
1
by: Kay | last post by:
I already specified to ignore specific library: MSVCPRT.lib MSVCRT.lib LIBC.lib MSVCRTD.lib LIBCD.lib command line is like: /INCREMENTAL /NOLOGO /DLL /NODEFAULTLIB:"MSVCPRT.lib MSVCRT.lib LIBC.lib...
6
by: Chris Stankevitz | last post by:
At link time, MSVC determines some of my libraries are unused and doesn't link them into my exe. This undesirable feature causes problems when I employ the factory pattern. With the factory...
0
by: Philip Lowman | last post by:
I am in the process of trying to migrate a couple of build solutions to Visual Studio Express 2005 from VS 2003 Professional and I am running into a weird C/C++ runtime library linking issue when...
0
by: ardentfreaker | last post by:
Hi Banfa and Everybody, This is my first post. Well, I have a problem with a Visual Studio .NET application and was wondering if anybody could help me with figuring out the solution. I have a...
2
by: =?Utf-8?B?RGV2?= | last post by:
I have a CLI/C++ library that links with a Native C++ library. Everything works and runs fine. However I get the following warning. warning LNK4075: ignoring '/EDITANDCONTINUE' due to...
7
by: =?Utf-8?B?UmFtZW5kcmEgS290aGFya2Fy?= | last post by:
Hello, I want to know how to statically link GDIPlus.dll with VC++ application that should be able to run on W2k machine without the existence of GDIPlus.dll on the target machine. Currently,...
2
by: Mohsen A. Momeni | last post by:
Hi, Does it have any difference in security, whether to compile a function as a static lib and link it with a program or just add the function to the source? In other words, suppose we have two...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...

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.