Giter Site home page Giter Site logo

Linker warning on OS X about tinyformat HOT 5 CLOSED

c42f avatar c42f commented on August 15, 2024
Linker warning on OS X

from tinyformat.

Comments (5)

c42f avatar c42f commented on August 15, 2024

The following two stack overflow questions seem to be relevant:

http://stackoverflow.com/questions/8685045/xcode-with-boost-linkerid-warning-about-visibility-settings
http://stackoverflow.com/questions/9894961/strange-warnings-from-the-linker-ld

From those posts I guess that this problem might be due to using tinyformat in two different projects with different default symbol visibilities, and then linking them together? In that case it's not a tinyformat problem per se - you should check your settings for "Symbols Hidden by Default" in xcode for both projects.

Can you tell me the compiler and version? Based on the error message, I'm assuming it's gcc.

from tinyformat.

beemaster avatar beemaster commented on August 15, 2024

Compiler is Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Most likely you are right, the problem is in project visibility settings.

I am using following setup:

  1. Static library that uses tinyformat. It has Symbols Hidden by Default set to NO. This is default XCode setting for static libraries.
  2. Application that uses both static library and tinyformat. It has Symbols Hidden by Default set to YES. This is default XCode setting for applications.

Since this is standard setup, I am not sure I want to change visibility settings. Do you think there is a possibility to change it in tinyformat?

from tinyformat.

c42f avatar c42f commented on August 15, 2024

There might be a workaround we could do in the source code. Perhaps it's as simple as adding __attribute__((visibility("hidden"))) attributes in a couple of places in the private FormatArg thunks? This would need to be behind a macro (TINYFORMAT_HIDDEN?) so that it doesn't mess up MSVC compatibility.

I can't reproduce this problem on linux with g++-4.8.2 or clang++-3.5, and I don't have ready access to OSX, but maybe you can get a cut down example going. Here's what I did:

Makefile:

CXX=clang++-3.5

INCLUDE=-I$(HOME)/dev/tinyformat

all: main

foo.o: Makefile foo.cpp foo.h
    $(CXX) -Wall $(INCLUDE) -c -fvisibility=default foo.cpp

test.o: Makefile test.cpp foo.h
    $(CXX) -Wall $(INCLUDE) -c -fvisibility=hidden test.cpp

main: Makefile test.o foo.o
    $(CXX) -Wall test.o foo.o -o main

foo.h:

#pragma once

void foo();

foo.cpp:

#include <tinyformat.h>
#include "foo.h"

void foo()
{
    tfm::printf("%d\n", 2);
}

test.cpp:

#include <tinyformat.h>

#include "foo.h"

int main()
{
    foo();
    tfm::printf("%d\n", 1);
    return 0;
}

from tinyformat.

beemaster avatar beemaster commented on August 15, 2024

I compiled your example and was able to reproduce the warning. The fix that you suggested worked well, thanks! I created a pull request #26

from tinyformat.

c42f avatar c42f commented on August 15, 2024

Fixed by #26

from tinyformat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.