Is there an equivalent of -I (capital I) for object files in g++?

Kvothe

I have several object files coming from different directories (they are stored near the corresponding source that generated them). Is there a way that given this directory structure

Root

main.o

Root/Some_long_path

object_1.o
object_2.o

I could run a command like this

g++ -Wall main.o -ISome_long_path object_1.o object_2.o -o app

So that I don't have to put the full path in front of every object file. What would go instead of the -I command?

I am using gcc version 4.8.3 (from Cygwin installation).

osgx

So that I don't have to put the full path in front of every object file. What would go instead of the -I command?

There is no gcc option like -I to add some directory to the object "search path", and there is no search path for objects. But there is search path for libraries (usually named lib*.a for static libraries and lib*.so for shared libraries in Unix world).

Directory-Options manual of gcc lists only -I option for include paths and -L option for library paths. There is no object path:

https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html#Directory-Options

And Link-Options manual of gcc mention only -L option (near -l description):

https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#Link-Options

What can you use:

  • shell variables or environment variables (in bash: OBJ_DIR=./path/to/dir then g++ ... $OBJ_DIR/obj1.o $OBJ_DIR/obj2.o)
  • Packing several objects from single directory to single static library libSome_Long_Component_Name.a (this type of library is just like the archive of several *.o object files and some extra info made with ar rcs); then you can use g++ ... -Ldir/ -lSome_Long_Component_Name
  • Makefiles and some variant of make utility (gnu make for linux and cygwin, nmake for windows's MSVC; you can start from gnu make manual: http://www.gnu.org/software/make/manual/make.html#Simple-Makefile then "2.4 Variables Make Makefiles Simpler" then "4.3 Types of Prerequisites" - with example of addprefix command to ask make find objects in some objdir. There is also VPATH special variable which instructs make to search sources and objects in several directories; but all objects in project should have different names).
  • Some IDE with support of Unix projects (Code::Blocks, list1, list2, wikilist of C/C++ IDE?); they usually manage all sources of you project and are able to generate Makefiles for project.
  • Some more modern build system, not the make: like CMake, SCons (or qmake if you use Qt).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Regex and Capital I in some cultures

What is the 'I' (capital i) flag in C printf?

can I use sed or an equivalent to cleanup vala generated files?

Can I get the equivalent of @JsonAnySetter functionality, outside of the object?

putting a capital 'I' in front of JAVA interfaces

Can I add object files as dependency?

Is ~i really equivalent to i != -1?

Is *s equivalent to s[i]?

g++ -I and -L commands to find .hpp files not working

Why is "i & (i ^ (i - 1))" equivalent to "i & (-i)"

In C, is { a[i] = a[++i] } equivalent to { a[i] = a[i+1]; i++;}?

How can I add spaces in string before non sequential capital letters, while excluding sequential capital letters?

How do I remove the substrings started with capital letters in a Python string?

How do I write a capital Greek "delta" as a string in Python 2.7?

How do I only accept capital letter as user input?

Should I use the commands My Sql in capital letters?

How can I write axis ticks in small capital using ggtext?

how to make the names I record in ArrayList start with a capital letter

How Can I count the number of Capital Cities within each Continent?

How can I detect all the capital letters in a string given by the user?

How to display android button text without dotted capital letter "I"?

How do I use italicized capital Greek letters in Matplotlib

How do I change the size of text between capital and lowercase letters?

How to press Ctrl + b + capital I (trying to install plugins in tmux)?

how can I filter capital letters in a data set

Why are <for i in obj:> and <for i in iter(obj):> equivalent?

Is &array[i] always equivalent to (array + i)?

Is there an equivalent to ( (ptr + i)->marks ), like ( ptr[i] .... )?

Grep | sed -i equivalent for Windows