Binary Output Path

Sysprogs forums Forums VisualGDB Binary Output Path

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #7434
    pedley
    Participant

    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?

    #7441
    support
    Keymaster

    Hi,

    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.

    #7450
    pedley
    Participant

    Thanks 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.

     

    #7459
    support
    Keymaster

    Hi,

    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.

    #7463
    pedley
    Participant

    Thanks, 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?

     

    #7486
    support
    Keymaster

    Hi,

    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?

    
    
    		
    	
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.