How to link the liblog4cplus.a static library in additional linker inputs?

Sysprogs forums Forums VisualGDB How to link the liblog4cplus.a static library in additional linker inputs?

This topic contains 7 replies, has 2 voices, and was last updated by  support 1 month, 3 weeks ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #25539

    andreeafurnica
    Participant

    I am using a visual GDB C++ project and I need to link the library liblog4cplus.a static library in the additiona linker inputs from the visual GDB properties.

    If I am giving the entire path to the library ……/liblog4cplus.a I receive some errors on build as below:

    Seems like the library is recognized but has some issues about the std=c++11 compilation.

    The liblog4cplus.a is compiled with std=c++11 correctly and I should not have this kind of error.

    I had this errors also when I linked the boost 1.62.0 library and I solved this using the command -L-library_name

    If I am using the command -L-log4cplus does not recognized the library.

    Could you please tell me if there is any other way to link a linux static library in the additional linker inputs?

     

    #25549

    support
    Keymaster

    Hi,

    This looks like the libstdc++ library bundled with your GCC may not contain the implementations for some functions required by the library.

    Please try building the library from sources using the same compiler. If you get c++11-related errors, the compiler does not provide the language support required by the library. If the build succeeds, the library should link to the main project without errors.

    Also depending on your compiler’s multilib configuration, you may need to specify -std=c++11 to the linker flags (and also ensure you are using g++, not gcc to link).

    #25556

    andreeafurnica
    Participant

    Hello,

    Im using -std=c++11 in linker flags but still have the same problem.

    I am using to type of libraries boost 1.62.0 and log4cplus 1.2.1 in the linker inputs which are both compiled with -std=c++11.

    The errors appear for both of them if I give the entire path to the libraries in the linker inputs: ../../../liblog4cplus.a and ../../../libboost_system.a.

    If I am using the command “-L-lboost_system”  for boost library instead of the entire path the error does not appear anymore and I can access all the boost functions.

    If I am using the command -L-log4cplus for log4cplus library I receive the error below:

    undefined reference to `log4cplus::Logger::~Logger()’

    The visual GDB accepts the command which means the library is found(I do not have errors when I put the command in linker), but on build the library is not recognized anymore like I did not linked it.

    Could you please tell me if I am using the right command to link the log4cplus library?

    There is other way to link it?

    Please find attached pictures with the GDB properties.

    Attachments:
    You must be logged in to view attached files.
    #25564

    support
    Keymaster

    Unfortunately, as you have cropped the project properties window screenshot, it’s hard to see which build subsystem you are using and give specific advice.

    Generally, the use of absolute paths vs. “-l” syntax should not affect the link outcome, as long as the libraries are found. Either way, the undefined reference to `log4cplus::Logger::~Logger()’ message means that the ~Logger() symbol is either missing, or the library providing it is specified outside the -start-group/-end-group pair (see this page for a discussion about linker groups).

    Please try enabling the verbose build logs and double-check that the the library paths end up between the -start-group and -end-group arguments. If not, please let us know the build system you are using (Make/CMake/QMake/MSBuild) and we will help you find the relevant settings.

    If the library is specified as expected, please check that the one of the source files in the library actually defines the ~Logger() symbol. You can read more about symbol declarations and definitions here: https://visualgdb.com/tutorials/tips/externc/

     

    #25567

    andreeafurnica
    Participant

    Hello,

    Please find attached pictures with all the Makefile settings and Project settings from Visual GDB properties and also for verbose mode.

    I am using GNU Make as build system.

    Could you please tell me If I enabled correctly the verbose build logs? I set it as detailed/diagnostic and I sow the detailed output logs, but I do not know how to interpret the information.

    The –start-group and –end-group property is checked as you can see in the picture, but I am not sure how to check that really all the linker path are between start-group and end-group commands as you said. Should I see in the Additional liker Input this commands as the first and the last command from linker, or that check box does that and only should be checked?

    In the debug.mak file I so that the –start-group and –end-group commands are saved so it should be ok.

    Attachments:
    You must be logged in to view attached files.
    #25572

    support
    Keymaster

    For GNU Make, the default log settings should already contain the necessary command lines.

    Please try rebuilding the project and check the output for the line containing liblog4cplus.a. Simply post that line here and we will help you understand it.

    #25573

    andreeafurnica
    Participant

    As I can see in the log, the library that actually fails is called logger.a which is a visual Visual GDB c++ project(static library) created by me that uses the log4cplus library. The project is build with the properties that I showed before(-std=c++11, –start-group, –end-group checked with the log4cplus as included library)

    Seems that the static library does not need the path to the liblog4cplus.a in the linker to compile correctly, it is only necessary to include the library folder in the include library property.

    Now I need to use this library logger.a into a Visual GDB project application and this requires also the path to the liblog4cplus.a in the linker inputs.

    This error does not appear when I build simply the project including the logger.h header. The error appears only when I make a call to a function that is in the library.

    What is very strange I that if I set my project as a “static library” not “executable” I do not have any errors and I can use all the functions but as executable I have this error . Do you know why this can happen?

     

    Below you can see the error messages that appears(verbose mode = diagnostic ).

    ..\..\..\Utilities\solution_linux\Debug\logger.a(Logger.o): In function std::pair<unsigned char const, log4cplus::Logger>::~pair()’:
    1> d:\sbx\gwtt_tool\nonembedded\visualstudio\dependencies\x64linuxcompiler\sysroots\i686-nilrtsdk-mingw32\usr\bin\x86_64-nilrt-linux\..\..\..\..\x86_64-nilrt-linux\usr\include\c++\4.7.2\bits\stl_pair.h(88): error : undefined reference to
    log4cplus::Logger::~Logger()’
    1> collect2.exe : error : ld returned 1 exit status
    1> make: *** [Debug/gwttl_generic_app] Error 1
    1> ————————————————————-
    1> Command exited with code 2
    1> Executable: C:\Program Files (x86)\Sysprogs\VisualGDB\make.exe
    1> Arguments: CONFIG=Debug
    1> Directory: D:\SBX\GWTT_TOOL\NonEmbedded\VisualStudio\Projects\Large\gwttl_generic_app
    1> VisualGDB : error : Command-line action failed
    1> C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command “”C:\Program Files (x86)\Sysprogs\VisualGDB\VisualGDB.exe” /build “D:\SBX\GWTT_TOOL\NonEmbedded\VisualStudio\Projects\Large\gwttl_generic_app\gwttl_generic_app.vcxproj” “/solution:D:\SBX\GWTT_TOOL\NonEmbedded\VisualStudio\Projects\Large\gwttl_generic_app\gwttl_generic_app.sln” “/config:Debug” “/platform:Win32″” exited with code 1.
    1> Done executing task “Exec” — FAILED.
    1>Done building target “Build” in project “gwttl_generic_app.vcxproj” — FAILED.
    1>
    1>Done building project “gwttl_generic_app.vcxproj” — FAILED.
    1>
    1>Project Performance Summary:
    1> 9308 ms D:\SBX\GWTT_TOOL\NonEmbedded\VisualStudio\Projects\Large\gwttl_generic_app\gwttl_generic_app.vcxproj 1 calls
    1>
    1>Target Performance Summary:
    1> 0 ms SetCABuildNativeEnvironmentVariables 1 calls
    1> 0 ms GetTargetPath 1 calls
    1> 0 ms BeforeResolveReferences 1 calls
    1> 0 ms _SplitProjectReferencesByFileExistence 1 calls
    1> 0 ms PrepareProjectReferences 1 calls
    1> 0 ms GetReferenceAssemblyPaths 1 calls
    1> 0 ms ExpandSDKReferences 1 calls
    1> 1 ms PrepareForBuild 1 calls
    1> 1 ms AssignProjectConfiguration 1 calls
    1> 1 ms ResolveReferences 1 calls
    1> 1 ms ResolveSDKReferences 1 calls
    1> 1 ms _GetProjectReferenceTargetFrameworkProperties 1 calls
    1> 1 ms AfterResolveReferences 1 calls
    1> 1 ms SetBuildDefaultEnvironmentVariables 1 calls
    1> 2 ms _CheckForInvalidConfigurationAndPlatform 1 calls
    1> 2 ms PrepareForNMakeBuild 1 calls
    1> 3 ms GetFrameworkPaths 1 calls
    1> 20 ms ResolveProjectReferences 1 calls
    1> 24 ms _HandlePackageFileConflicts 1 calls
    1> 48 ms ResolveAssemblyReferences 1 calls
    1> 9185 ms Build 1 calls
    1>
    1>Task Performance Summary:
    1> 1 ms Message 2 calls
    1> 1 ms FindAppConfigFile 1 calls
    1> 1 ms MakeDir 2 calls
    1> 1 ms AssignProjectConfiguration 1 calls
    1> 1 ms MSBuild 1 calls
    1> 1 ms SetEnv 5 calls
    1> 23 ms ResolvePackageFileConflicts 1 calls
    1> 47 ms ResolveAssemblyReference 1 calls
    1> 9185 ms Exec 1 calls
    1>
    1>Build FAILED.
    1>
    1>D:\SBX\GWTT_TOOL\NonEmbedded\VisualStudio\Projects\Large\gwttl_generic_app\..\..\..\Wrappers\_src\Sequencer.h(34,54): warning : ‘visibility’ attribute ignored [-Wattributes]
    1>D:\SBX\GWTT_TOOL\NonEmbedded\VisualStudio\Projects\Large\gwttl_generic_app\..\..\..\Wrappers\_src\Sequencer.h(44,46): warning : ‘visibility’ attribute ignored [-Wattributes]
    1>D:\SBX\GWTT_TOOL\NonEmbedded\VisualStudio\Projects\Large\gwttl_generic_app\..\..\..\Wrappers\_src\Sequencer.h(91,43): warning : ‘visibility’ attribute ignored [-Wattributes]
    1>D:\SBX\GWTT_TOOL\NonEmbedded\VisualStudio\Projects\Large\gwttl_generic_app\..\..\..\Wrappers\_src\LFWrapper.h(26,18): warning : attribute ignored in declaration of ‘struct LFSync’ [enabled by default]
    1>D:\SBX\GWTT_TOOL\NonEmbedded\VisualStudio\Projects\Large\gwttl_generic_app\..\..\..\Wrappers\_src\LFWrapper.h(26,18): warning : attribute for ‘struct LFSync’ must follow the ‘struct’ keyword [enabled by default]
    1>d:\sbx\gwtt_tool\nonembedded\visualstudio\dependencies\x64linuxcompiler\sysroots\i686-nilrtsdk-mingw32\usr\bin\x86_64-nilrt-linux\..\..\..\..\x86_64-nilrt-linux\usr\include\c++\4.7.2\bits\stl_pair.h(88): error : undefined reference to `log4cplus::Logger::~Logger()’
    1>collect2.exe : error : ld returned 1 exit status
    1>VisualGDB : error : Command-line action failed
    1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command “”C:\Program Files (x86)\Sysprogs\VisualGDB\VisualGDB.exe” /build “D:\SBX\GWTT_TOOL\NonEmbedded\VisualStudio\Projects\Large\gwttl_generic_app\gwttl_generic_app.vcxproj” “/solution:D:\SBX\GWTT_TOOL\NonEmbedded\VisualStudio\Projects\Large\gwttl_generic_app\gwttl_generic_app.sln” “/config:Debug” “/platform:Win32″” exited with code 1.
    1> 5 Warning(s)
    1> 4 Error(s)

    #25574

    support
    Keymaster

    Sorry, unfortunately the log you posted is missing the link command line that would be shown at the beginning. Please attach the entire log, not just the bottom part of it (you don’t need to enable verbose logging on VS level for Make projects, as they handle verbosity on a separate level).

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.