FAQ
I apologize in advance for what I am sure is a duplicate topic. I tried to
find the previous thread where I remember this topic being addressed, but
failed to find it.

I've been happily building my OpenImageIO
<https://github.com/justinfx/openimageigo> bindings via the standard
dynamic linking to libOpenImageIO, but am now trying to build statically.
I'm running into an issue where no matter what combination of flags I try,
the external linker fails with a ton of "undefined reference" errors. From
the thread I can remember in the past, I recall it being said that there
was an issue regarding the order in which the linker saw the symbols.

Here is a brief example of my build attempt, trying to get it to build
against static builds of boost/OpenColorIO/OpenImageIO :

===
$ export CGO_CPPFLAGS="\
-I/path/to/boost/include \
-I/path/to/OpenColorIO/include \
-I/path/to/OpenImageIO/include"

$ export CGO_LDFLAGS="\
-L/path/to/boost/lib -lboost_thread_static -lboost_system_static \
-L/path/to/OpenColorIO/lib -lopencolorio \
-L/path/to/OpenImageIO/lib -lOpenImageIO"

$ go build -v -x --ldflags '-extldflags "-static"'
  github.com/justinfx/openimageigo
...
CGO_LDFLAGS="/path/to/boost/lib/libboost_system_static.a"
"/path/to/boost/lib/libboost_thread_static.a"
"/path/to/OpenColorIO/lib/libopencolorio.a"
"/path/to/OpenImageIO/lib/libOpenImageIO.a" "-lstdc++"
/vol/apps/go/1.3.0/pkg/tool/linux_amd64/cgo -objdir
$WORK/github.com/justinfx/openimageigo/_obj/ -- -I/path/to/boost/include
-I/path/to/OpenColorIO/include -I/path/to/OpenImageIO/include -I./cpp -I
$WORK/github.com/justinfx/openimageigo/_obj/ -I/path/to/boost/include
-I/path/to/OpenColorIO/include -I/path/to/OpenImageIO/include color.go
imagebuf.go imagebufalgo.go imagecache.go imageinput.go imageoutput.go
imagespec.go oiio.go roi.go
...
/usr/bin/g++ -I . -fPIC -m64 -pthread -fmessage-length=0
-I/path/to/boost/include -I/path/to/OpenColorIO/include
-I/path/to/OpenImageIO/include -I./cpp -I
$WORK/github.com/justinfx/openimageigo/_obj/ -g -O2 -o
$WORK/github.com/justinfx/openimageigo/_obj/all.cpp.o -c ./all.cpp

/usr/bin/g++ -I . -fPIC -m64 -pthread -fmessage-length=0 -o
$WORK/github.com/justinfx/openimageigo/_obj/_cgo_.o
$WORK/github.com/justinfx/openimageigo/_obj/_cgo_main.o
$WORK/github.com/justinfx/openimageigo/_obj/_cgo_export.o
$WORK/github.com/justinfx/openimageigo/_obj/color.cgo2.o
$WORK/github.com/justinfx/openimageigo/_obj/imagebuf.cgo2.o
$WORK/github.com/justinfx/openimageigo/_obj/imagebufalgo.cgo2.o
$WORK/github.com/justinfx/openimageigo/_obj/imagecache.cgo2.o
$WORK/github.com/justinfx/openimageigo/_obj/imageinput.cgo2.o
$WORK/github.com/justinfx/openimageigo/_obj/imageoutput.cgo2.o
$WORK/github.com/justinfx/openimageigo/_obj/imagespec.cgo2.o
$WORK/github.com/justinfx/openimageigo/_obj/oiio.cgo2.o
$WORK/github.com/justinfx/openimageigo/_obj/roi.cgo2.o
$WORK/github.com/justinfx/openimageigo/_obj/all.cpp.o
/path/to/boost/lib/libboost_system_static.a
/path/to/boost/lib/libboost_thread_static.a
/path/to/OpenColorIO/lib/libopencolorio.a
/path/to/OpenImageIO/lib/libOpenImageIO.a -lstdc++
===

And here are some of the cherry-picked errors, since it was a very long bit
of output:

/path/to/OpenImageIO/lib/libOpenImageIO.a(OpenImageIO_dist^src^libOpenImageIO^color_ocio.cpp.o):
In function `ColorConfig':
/path/to/OpenImageIO/OpenImageIO_dist/src/libOpenImageIO/color_ocio.cpp:141:
undefined reference to
`OpenColorIO::v1::SetLoggingLevel(OpenColorIO::v1::LoggingLevel)'
...
/path/to/OpenImageIO/lib/libOpenImageIO.a(OpenImageIO_dist^src^libOpenImageIO^imagebufalgo_copy.cpp.o):
In function `boost::shared_mutex::lock()':
/path/to/boost/include/boost/thread/pthread/shared_mutex.hpp:138: undefined
reference to
`boost::this_thread::disable_interruption::~disable_interruption()'

OpenImageIO can't seem to find references for OpenColorIO
OpenImageIO can't seem to find references for boost

I'm hoping I am doing something simple and stupid that can be corrected in
my build process. But the cgo static linking with external libs does seem a
touch more complicated than the default dynamic linking.

-- justin




--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Roger Pack at Aug 14, 2014 at 4:48 pm

    On Tuesday, July 1, 2014 9:34:28 PM UTC-6, Justin Israel wrote:
    I apologize in advance for what I am sure is a duplicate topic. I tried to
    find the previous thread where I remember this topic being addressed, but
    failed to find it.
    The discussion here may be interesting to you:
    https://code.google.com/p/go/issues/detail?id=8442 [in case it gives hints
    on debugging issues like this, that's all]

    I've been happily building my OpenImageIO
    <https://github.com/justinfx/openimageigo> bindings via the standard
    dynamic linking to libOpenImageIO, but am now trying to build statically.
    I'm running into an issue where no matter what combination of flags I try,
    the external linker fails with a ton of "undefined reference" errors. From
    the thread I can remember in the past, I recall it being said that there
    was an issue regarding the order in which the linker saw the symbols.

    Here is a brief example of my build attempt, trying to get it to build
    against static builds of boost/OpenColorIO/OpenImageIO :

    ===
    $ export CGO_CPPFLAGS="\
    -I/path/to/boost/include \
    -I/path/to/OpenColorIO/include \
    -I/path/to/OpenImageIO/include"

    $ export CGO_LDFLAGS="\
    -L/path/to/boost/lib -lboost_thread_static -lboost_system_static \
    -L/path/to/OpenColorIO/lib -lopencolorio \
    -L/path/to/OpenImageIO/lib -lOpenImageIO"

    $ go build -v -x --ldflags '-extldflags "-static"'
    github.com/justinfx/openimageigo
    ...
    CGO_LDFLAGS="/path/to/boost/lib/libboost_system_static.a"
    "/path/to/boost/lib/libboost_thread_static.a"
    "/path/to/OpenColorIO/lib/libopencolorio.a"
    "/path/to/OpenImageIO/lib/libOpenImageIO.a" "-lstdc++"
    /vol/apps/go/1.3.0/pkg/tool/linux_amd64/cgo -objdir $WORK/
    github.com/justinfx/openimageigo/_obj/ -- -I/path/to/boost/include
    -I/path/to/OpenColorIO/include -I/path/to/OpenImageIO/include -I./cpp -I
    $WORK/github.com/justinfx/openimageigo/_obj/ -I/path/to/boost/include
    -I/path/to/OpenColorIO/include -I/path/to/OpenImageIO/include color.go
    imagebuf.go imagebufalgo.go imagecache.go imageinput.go imageoutput.go
    imagespec.go oiio.go roi.go
    ...
    /usr/bin/g++ -I . -fPIC -m64 -pthread -fmessage-length=0
    -I/path/to/boost/include -I/path/to/OpenColorIO/include
    -I/path/to/OpenImageIO/include -I./cpp -I $WORK/
    github.com/justinfx/openimageigo/_obj/ -g -O2 -o $WORK/
    github.com/justinfx/openimageigo/_obj/all.cpp.o -c ./all.cpp

    /usr/bin/g++ -I . -fPIC -m64 -pthread -fmessage-length=0 -o $WORK/
    github.com/justinfx/openimageigo/_obj/_cgo_.o $WORK/
    github.com/justinfx/openimageigo/_obj/_cgo_main.o $WORK/
    github.com/justinfx/openimageigo/_obj/_cgo_export.o $WORK/
    github.com/justinfx/openimageigo/_obj/color.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/imagebuf.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/imagebufalgo.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/imagecache.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/imageinput.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/imageoutput.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/imagespec.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/oiio.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/roi.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/all.cpp.o
    /path/to/boost/lib/libboost_system_static.a
    /path/to/boost/lib/libboost_thread_static.a
    /path/to/OpenColorIO/lib/libopencolorio.a
    /path/to/OpenImageIO/lib/libOpenImageIO.a -lstdc++
    ===

    And here are some of the cherry-picked errors, since it was a very long
    bit of output:

    /path/to/OpenImageIO/lib/libOpenImageIO.a(OpenImageIO_dist^src^libOpenImageIO^color_ocio.cpp.o):
    In function `ColorConfig':
    /path/to/OpenImageIO/OpenImageIO_dist/src/libOpenImageIO/color_ocio.cpp:141:
    undefined reference to
    `OpenColorIO::v1::SetLoggingLevel(OpenColorIO::v1::LoggingLevel)'
    ...
    /path/to/OpenImageIO/lib/libOpenImageIO.a(OpenImageIO_dist^src^libOpenImageIO^imagebufalgo_copy.cpp.o):
    In function `boost::shared_mutex::lock()':
    /path/to/boost/include/boost/thread/pthread/shared_mutex.hpp:138:
    undefined reference to
    `boost::this_thread::disable_interruption::~disable_interruption()'

    OpenImageIO can't seem to find references for OpenColorIO
    OpenImageIO can't seem to find references for boost

    I'm hoping I am doing something simple and stupid that can be corrected in
    my build process. But the cgo static linking with external libs does seem a
    touch more complicated than the default dynamic linking.

    -- justin



    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • James Bardin at Aug 14, 2014 at 5:02 pm
    I don't know if OpenImageIO does, but many projects also supply pkg-config
    files, so that you can query for the linking information you need (and cgo
    has a pkg-config directive, though it doesn't query for --static)


    On Thursday, August 14, 2014 12:48:00 PM UTC-4, Roger Pack wrote:


    On Tuesday, July 1, 2014 9:34:28 PM UTC-6, Justin Israel wrote:

    I apologize in advance for what I am sure is a duplicate topic. I tried
    to find the previous thread where I remember this topic being addressed,
    but failed to find it.
    The discussion here may be interesting to you:
    https://code.google.com/p/go/issues/detail?id=8442 [in case it gives
    hints on debugging issues like this, that's all]

    I've been happily building my OpenImageIO
    <https://github.com/justinfx/openimageigo> bindings via the standard
    dynamic linking to libOpenImageIO, but am now trying to build statically.
    I'm running into an issue where no matter what combination of flags I try,
    the external linker fails with a ton of "undefined reference" errors. From
    the thread I can remember in the past, I recall it being said that there
    was an issue regarding the order in which the linker saw the symbols.

    Here is a brief example of my build attempt, trying to get it to build
    against static builds of boost/OpenColorIO/OpenImageIO :

    ===
    $ export CGO_CPPFLAGS="\
    -I/path/to/boost/include \
    -I/path/to/OpenColorIO/include \
    -I/path/to/OpenImageIO/include"

    $ export CGO_LDFLAGS="\
    -L/path/to/boost/lib -lboost_thread_static -lboost_system_static \
    -L/path/to/OpenColorIO/lib -lopencolorio \
    -L/path/to/OpenImageIO/lib -lOpenImageIO"

    $ go build -v -x --ldflags '-extldflags "-static"'
    github.com/justinfx/openimageigo
    ...
    CGO_LDFLAGS="/path/to/boost/lib/libboost_system_static.a"
    "/path/to/boost/lib/libboost_thread_static.a"
    "/path/to/OpenColorIO/lib/libopencolorio.a"
    "/path/to/OpenImageIO/lib/libOpenImageIO.a" "-lstdc++"
    /vol/apps/go/1.3.0/pkg/tool/linux_amd64/cgo -objdir $WORK/
    github.com/justinfx/openimageigo/_obj/ -- -I/path/to/boost/include
    -I/path/to/OpenColorIO/include -I/path/to/OpenImageIO/include -I./cpp -I
    $WORK/github.com/justinfx/openimageigo/_obj/ -I/path/to/boost/include
    -I/path/to/OpenColorIO/include -I/path/to/OpenImageIO/include color.go
    imagebuf.go imagebufalgo.go imagecache.go imageinput.go imageoutput.go
    imagespec.go oiio.go roi.go
    ...
    /usr/bin/g++ -I . -fPIC -m64 -pthread -fmessage-length=0
    -I/path/to/boost/include -I/path/to/OpenColorIO/include
    -I/path/to/OpenImageIO/include -I./cpp -I $WORK/
    github.com/justinfx/openimageigo/_obj/ -g -O2 -o $WORK/
    github.com/justinfx/openimageigo/_obj/all.cpp.o -c ./all.cpp

    /usr/bin/g++ -I . -fPIC -m64 -pthread -fmessage-length=0 -o $WORK/
    github.com/justinfx/openimageigo/_obj/_cgo_.o $WORK/
    github.com/justinfx/openimageigo/_obj/_cgo_main.o $WORK/
    github.com/justinfx/openimageigo/_obj/_cgo_export.o $WORK/
    github.com/justinfx/openimageigo/_obj/color.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/imagebuf.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/imagebufalgo.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/imagecache.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/imageinput.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/imageoutput.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/imagespec.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/oiio.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/roi.cgo2.o $WORK/
    github.com/justinfx/openimageigo/_obj/all.cpp.o
    /path/to/boost/lib/libboost_system_static.a
    /path/to/boost/lib/libboost_thread_static.a
    /path/to/OpenColorIO/lib/libopencolorio.a
    /path/to/OpenImageIO/lib/libOpenImageIO.a -lstdc++
    ===

    And here are some of the cherry-picked errors, since it was a very long
    bit of output:

    /path/to/OpenImageIO/lib/libOpenImageIO.a(OpenImageIO_dist^src^libOpenImageIO^color_ocio.cpp.o):
    In function `ColorConfig':
    /path/to/OpenImageIO/OpenImageIO_dist/src/libOpenImageIO/color_ocio.cpp:141:
    undefined reference to
    `OpenColorIO::v1::SetLoggingLevel(OpenColorIO::v1::LoggingLevel)'
    ...
    /path/to/OpenImageIO/lib/libOpenImageIO.a(OpenImageIO_dist^src^libOpenImageIO^imagebufalgo_copy.cpp.o):
    In function `boost::shared_mutex::lock()':
    /path/to/boost/include/boost/thread/pthread/shared_mutex.hpp:138:
    undefined reference to
    `boost::this_thread::disable_interruption::~disable_interruption()'

    OpenImageIO can't seem to find references for OpenColorIO
    OpenImageIO can't seem to find references for boost

    I'm hoping I am doing something simple and stupid that can be corrected
    in my build process. But the cgo static linking with external libs does
    seem a touch more complicated than the default dynamic linking.

    -- justin



    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Justin Israel at Aug 14, 2014 at 7:38 pm
    I was silly and had the wrong order of libs for static linking. Finally
    got it all working.

    thanks!
    On 15/08/2014 5:02 AM, "James Bardin" wrote:

    I don't know if OpenImageIO does, but many projects also supply pkg-config
    files, so that you can query for the linking information you need (and cgo
    has a pkg-config directive, though it doesn't query for --static)


    On Thursday, August 14, 2014 12:48:00 PM UTC-4, Roger Pack wrote:


    On Tuesday, July 1, 2014 9:34:28 PM UTC-6, Justin Israel wrote:

    I apologize in advance for what I am sure is a duplicate topic. I tried
    to find the previous thread where I remember this topic being addressed,
    but failed to find it.
    The discussion here may be interesting to you:
    https://code.google.com/p/go/issues/detail?id=8442 [in case it gives
    hints on debugging issues like this, that's all]

    I've been happily building my OpenImageIO
    <https://github.com/justinfx/openimageigo> bindings via the standard
    dynamic linking to libOpenImageIO, but am now trying to build statically.
    I'm running into an issue where no matter what combination of flags I try,
    the external linker fails with a ton of "undefined reference" errors. From
    the thread I can remember in the past, I recall it being said that there
    was an issue regarding the order in which the linker saw the symbols.

    Here is a brief example of my build attempt, trying to get it to build
    against static builds of boost/OpenColorIO/OpenImageIO :

    ===
    $ export CGO_CPPFLAGS="\
    -I/path/to/boost/include \
    -I/path/to/OpenColorIO/include \
    -I/path/to/OpenImageIO/include"

    $ export CGO_LDFLAGS="\
    -L/path/to/boost/lib -lboost_thread_static -lboost_system_static \
    -L/path/to/OpenColorIO/lib -lopencolorio \
    -L/path/to/OpenImageIO/lib -lOpenImageIO"

    $ go build -v -x --ldflags '-extldflags "-static"' github.com/justinfx/
    openimageigo
    ...
    CGO_LDFLAGS="/path/to/boost/lib/libboost_system_static.a"
    "/path/to/boost/lib/libboost_thread_static.a" "/path/to/OpenColorIO/lib/libopencolorio.a"
    "/path/to/OpenImageIO/lib/libOpenImageIO.a" "-lstdc++"
    /vol/apps/go/1.3.0/pkg/tool/linux_amd64/cgo -objdir $WORK/
    github.com/justinfx/openimageigo/_obj/ -- -I/path/to/boost/include
    -I/path/to/OpenColorIO/include -I/path/to/OpenImageIO/include -I./cpp -I
    $WORK/github.com/justinfx/openimageigo/_obj/ -I/path/to/boost/include
    -I/path/to/OpenColorIO/include -I/path/to/OpenImageIO/include color.go
    imagebuf.go imagebufalgo.go imagecache.go imageinput.go imageoutput.go
    imagespec.go oiio.go roi.go
    ...
    /usr/bin/g++ -I . -fPIC -m64 -pthread -fmessage-length=0
    -I/path/to/boost/include -I/path/to/OpenColorIO/include
    -I/path/to/OpenImageIO/include -I./cpp -I $WORK/github.com/justinfx/
    openimageigo/_obj/ -g -O2 -o $WORK/github.com/justinfx/
    openimageigo/_obj/all.cpp.o -c ./all.cpp

    /usr/bin/g++ -I . -fPIC -m64 -pthread -fmessage-length=0 -o $WORK/
    github.com/justinfx/openimageigo/_obj/_cgo_.o $WORK/github.com/justinfx/
    openimageigo/_obj/_cgo_main.o $WORK/github.com/justinfx/
    openimageigo/_obj/_cgo_export.o $WORK/github.com/justinfx/
    openimageigo/_obj/color.cgo2.o $WORK/github.com/justinfx/
    openimageigo/_obj/imagebuf.cgo2.o $WORK/github.com/justinfx/
    openimageigo/_obj/imagebufalgo.cgo2.o $WORK/github.com/justinfx/
    openimageigo/_obj/imagecache.cgo2.o $WORK/github.com/justinfx/
    openimageigo/_obj/imageinput.cgo2.o $WORK/github.com/justinfx/
    openimageigo/_obj/imageoutput.cgo2.o $WORK/github.com/justinfx/
    openimageigo/_obj/imagespec.cgo2.o $WORK/github.com/justinfx/
    openimageigo/_obj/oiio.cgo2.o $WORK/github.com/justinfx/
    openimageigo/_obj/roi.cgo2.o $WORK/github.com/justinfx/
    openimageigo/_obj/all.cpp.o /path/to/boost/lib/libboost_system_static.a
    /path/to/boost/lib/libboost_thread_static.a /path/to/OpenColorIO/lib/libopencolorio.a
    /path/to/OpenImageIO/lib/libOpenImageIO.a -lstdc++
    ===

    And here are some of the cherry-picked errors, since it was a very long
    bit of output:

    /path/to/OpenImageIO/lib/libOpenImageIO.a(OpenImageIO_
    dist^src^libOpenImageIO^color_ocio.cpp.o): In function `ColorConfig':
    /path/to/OpenImageIO/OpenImageIO_dist/src/libOpenImageIO/color_ocio.cpp:141:
    undefined reference to `OpenColorIO::v1::SetLoggingLevel(OpenColorIO::
    v1::LoggingLevel)'
    ...
    /path/to/OpenImageIO/lib/libOpenImageIO.a(OpenImageIO_
    dist^src^libOpenImageIO^imagebufalgo_copy.cpp.o): In function
    `boost::shared_mutex::lock()':
    /path/to/boost/include/boost/thread/pthread/shared_mutex.hpp:138:
    undefined reference to `boost::this_thread::disable_
    interruption::~disable_interruption()'

    OpenImageIO can't seem to find references for OpenColorIO
    OpenImageIO can't seem to find references for boost

    I'm hoping I am doing something simple and stupid that can be corrected
    in my build process. But the cgo static linking with external libs does
    seem a touch more complicated than the default dynamic linking.

    -- justin




    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJul 2, '14 at 3:34a
activeAug 14, '14 at 7:38p
posts4
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase