Sysprogs forums › Forums › VisualGDB › Binary Output Path
- This topic has 5 replies, 2 voices, and was last updated 8 years, 10 months ago by support.
-
AuthorPosts
-
January 5, 2016 at 20:20 #7434pedleyParticipant
I am using VS2012, compiling on the PC and running on a Pi. I am developing a largish project in modules and saving each to a static library. Each module is a ‘solution’, together with its own test program.
I would like to have all of these static libraries in the same folder on the PC for ease of access/linker parameters, as there are several dependencies. However, I can’t see how to specify the output path for the binary to be other than the local Debug or Release folder. Obviously I could copy the library manually but this is tedious and error-prone.
How to specify a custom output path for a static library, please?
January 8, 2016 at 05:26 #7441supportKeymasterHi,
You can change the output directory on the Makefile Settings page of VisualGDB Project Properties. However, if you have several projects in the same directory, you would need to change the Makefile names for them (same page of properties) to ensure that they are using different Makefiles and their settings are stored separately.
January 8, 2016 at 13:47 #7450pedleyParticipantThanks Bazis.
I have eventually worked it out but it is not very pretty. For anyone else looking to do the same thing, the solution was to add a path to the output file name to back it out of the default binary directory, then back into the required one. In my case eg “../../../../Lib/libDpExcepIf.a”. By doing this on the ‘Output file name’, rather than the ‘Binary directory’, it leaves the intermediate object files in the default binary directory and the target directory clean, with just the library files. Not sure how efficient it is but it seems to work.
Each project is in a separate subdirectory (which, for linking purposes, is why it is desirable to keep all output libraries in one place), so makefile names are not a problem.
January 12, 2016 at 02:48 #7459supportKeymasterHi,
Yes, that would work. You can also add a command to the Makefile to copy the built library to a common output directory after it is linked. Let us know if you need a detailed example on that.
January 12, 2016 at 12:36 #7463pedleyParticipantThanks, Bazis.
Just to note that this doesn’t work for shared .so libraries when using the cross-compiler. The relative path is somehow encoded with the library file and is used on the execution machine (and hence the library not found).
I would appreciate an example of doing this via the Makefile. In what circumstances would any changes to the Makefile be overwritten by VGDB?
January 16, 2016 at 04:22 #7486supportKeymasterHi,
Here’s an example of modifying the Makefile to copy your .so file in the ..\AllLibraries directory (it assumes that you are building on Windows with a cross-compiler):
../AllLibraries: mkdir ..\AllLibraries ifeq ($(TARGETTYPE),SHARED) $(BINARYDIR)/$(TARGETNAME): $(all_objs) $(EXTERNAL_LIBS) ../AllLibraries $(LD) -shared -o $@ $(LDFLAGS) $(START_GROUP) $(all_objs) $(LIBRARY_LDFLAGS) $(END_GROUP) copy /y $(subst /,\,$@) ..\AllLibraries\$(notdir $@) endif
VisualGDB does not overwrite the Makefile, it carefully adjusts parts of it (e.g. the SOURCEFILES assignment line and the lines below the #VisualGDB: GeneratedRules marker).
Normally VisualGDB should add the -Wl,–rpath=’$$ORIGIN’ flag to linker flags and that should add an attribute to the linked file telling the library loader to check the directory of the executable for missing library dependencies. Do you see this flag in your build log?
-
AuthorPosts
- You must be logged in to reply to this topic.