New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build Yoga 2.0 as a shared library (partial implementation). #1341
Comments
It’s hard to tell what the issue is with the limited error output. Instead of changing yogacore to be either a shared or static library, it might be easier to link the static library into a new shared library. As a reference, the JNI bindings do just this, and link in some more code which is binding specific to a final libyoga.so. https://github.com/facebook/yoga/blob/main/java/CMakeLists.txt. |
I was able to get this buy using [ 90%] Building CXX object tests/CMakeFiles/yogatests.dir/generated/YGRoundingTest.cpp.o
cd /home/sstarr/Downloads/yoga-2.0.0/build/tests && /usr/bin/c++ -I/home/sstarr/Downloads/yoga-2.0.0/yoga/.. -isystem /home/sstarr/Downloads/yoga-2.0.0/build/_deps/googletest-src/googletest/include -isystem /home/sstarr/Downloads/yoga-2.0.0/build/_deps/googletest-src/googletest -fPIE -fvisibility=hidden -fno-omit-frame-pointer -fexceptions -Wall -Wextra -Werror -fno-rtti -std=gnu++14 -MD -MT tests/CMakeFiles/yogatests.dir/generated/YGRoundingTest.cpp.o -MF CMakeFiles/yogatests.dir/generated/YGRoundingTest.cpp.o.d -o CMakeFiles/yogatests.dir/generated/YGRoundingTest.cpp.o -c /home/sstarr/Downloads/yoga-2.0.0/tests/generated/YGRoundingTest.cpp
[ 91%] Building CXX object tests/CMakeFiles/yogatests.dir/generated/YGSizeOverflowTest.cpp.o
cd /home/sstarr/Downloads/yoga-2.0.0/build/tests && /usr/bin/c++ -I/home/sstarr/Downloads/yoga-2.0.0/yoga/.. -isystem /home/sstarr/Downloads/yoga-2.0.0/build/_deps/googletest-src/googletest/include -isystem /home/sstarr/Downloads/yoga-2.0.0/build/_deps/googletest-src/googletest -fPIE -fvisibility=hidden -fno-omit-frame-pointer -fexceptions -Wall -Wextra -Werror -fno-rtti -std=gnu++14 -MD -MT tests/CMakeFiles/yogatests.dir/generated/YGSizeOverflowTest.cpp.o -MF CMakeFiles/yogatests.dir/generated/YGSizeOverflowTest.cpp.o.d -o CMakeFiles/yogatests.dir/generated/YGSizeOverflowTest.cpp.o -c /home/sstarr/Downloads/yoga-2.0.0/tests/generated/YGSizeOverflowTest.cpp
[ 92%] Building CXX object tests/CMakeFiles/yogatests.dir/util/TestUtil.cpp.o
cd /home/sstarr/Downloads/yoga-2.0.0/build/tests && /usr/bin/c++ -I/home/sstarr/Downloads/yoga-2.0.0/yoga/.. -isystem /home/sstarr/Downloads/yoga-2.0.0/build/_deps/googletest-src/googletest/include -isystem /home/sstarr/Downloads/yoga-2.0.0/build/_deps/googletest-src/googletest -fPIE -fvisibility=hidden -fno-omit-frame-pointer -fexceptions -Wall -Wextra -Werror -fno-rtti -std=gnu++14 -MD -MT tests/CMakeFiles/yogatests.dir/util/TestUtil.cpp.o -MF CMakeFiles/yogatests.dir/util/TestUtil.cpp.o.d -o CMakeFiles/yogatests.dir/util/TestUtil.cpp.o -c /home/sstarr/Downloads/yoga-2.0.0/tests/util/TestUtil.cpp
[ 94%] Linking CXX executable yogatests
cd /home/sstarr/Downloads/yoga-2.0.0/build/tests && /usr/bin/cmake -E cmake_link_script CMakeFiles/yogatests.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/yogatests.dir/BitUtilsTest.cpp.o CMakeFiles/yogatests.dir/CompactValueTest.cpp.o CMakeFiles/yogatests.dir/EventsTest.cpp.o CMakeFiles/yogatests.dir/YGAlignBaselineTest.cpp.o CMakeFiles/yogatests.dir/YGAspectRatioTest.cpp.o CMakeFiles/yogatests.dir/YGBaselineFuncTest.cpp.o CMakeFiles/yogatests.dir/YGComputedMarginTest.cpp.o CMakeFiles/yogatests.dir/YGComputedPaddingTest.cpp.o CMakeFiles/yogatests.dir/YGDefaultValuesTest.cpp.o CMakeFiles/yogatests.dir/YGDirtiedTest.cpp.o CMakeFiles/yogatests.dir/YGDirtyMarkingTest.cpp.o CMakeFiles/yogatests.dir/YGEdgeTest.cpp.o CMakeFiles/yogatests.dir/YGFloatOptionalTest.cpp.o CMakeFiles/yogatests.dir/YGHadOverflowTest.cpp.o CMakeFiles/yogatests.dir/YGLoggerTest.cpp.o CMakeFiles/yogatests.dir/YGMeasureCacheTest.cpp.o CMakeFiles/yogatests.dir/YGMeasureModeTest.cpp.o CMakeFiles/yogatests.dir/YGMeasureTest.cpp.o CMakeFiles/yogatests.dir/YGNodeCallbackTest.cpp.o CMakeFiles/yogatests.dir/YGNodeChildTest.cpp.o CMakeFiles/yogatests.dir/YGPersistenceTest.cpp.o CMakeFiles/yogatests.dir/YGRelayoutTest.cpp.o CMakeFiles/yogatests.dir/YGRoundingFunctionTest.cpp.o CMakeFiles/yogatests.dir/YGRoundingMeasureFuncTest.cpp.o CMakeFiles/yogatests.dir/YGStyleAccessorsTest.cpp.o CMakeFiles/yogatests.dir/YGStyleTest.cpp.o CMakeFiles/yogatests.dir/YGTreeMutationTest.cpp.o CMakeFiles/yogatests.dir/YGValueTest.cpp.o CMakeFiles/yogatests.dir/YGZeroOutLayoutRecursivlyTest.cpp.o CMakeFiles/yogatests.dir/generated/YGAbsolutePositionTest.cpp.o CMakeFiles/yogatests.dir/generated/YGAlignContentTest.cpp.o CMakeFiles/yogatests.dir/generated/YGAlignItemsTest.cpp.o CMakeFiles/yogatests.dir/generated/YGAlignSelfTest.cpp.o CMakeFiles/yogatests.dir/generated/YGAndroidNewsFeed.cpp.o CMakeFiles/yogatests.dir/generated/YGBorderTest.cpp.o CMakeFiles/yogatests.dir/generated/YGConfigTest.cpp.o CMakeFiles/yogatests.dir/generated/YGDimensionTest.cpp.o CMakeFiles/yogatests.dir/generated/YGDisplayTest.cpp.o CMakeFiles/yogatests.dir/generated/YGFlexDirectionTest.cpp.o CMakeFiles/yogatests.dir/generated/YGFlexTest.cpp.o CMakeFiles/yogatests.dir/generated/YGFlexWrapTest.cpp.o CMakeFiles/yogatests.dir/generated/YGGapTest.cpp.o CMakeFiles/yogatests.dir/generated/YGJustifyContentTest.cpp.o CMakeFiles/yogatests.dir/generated/YGMarginTest.cpp.o CMakeFiles/yogatests.dir/generated/YGMinMaxDimensionTest.cpp.o CMakeFiles/yogatests.dir/generated/YGPaddingTest.cpp.o CMakeFiles/yogatests.dir/generated/YGPercentageTest.cpp.o CMakeFiles/yogatests.dir/generated/YGRoundingTest.cpp.o CMakeFiles/yogatests.dir/generated/YGSizeOverflowTest.cpp.o CMakeFiles/yogatests.dir/util/TestUtil.cpp.o -o yogatests -Wl,-rpath,/home/sstarr/Downloads/yoga-2.0.0/build/yoga:/home/sstarr/Downloads/yoga-2.0.0/build/lib ../yoga/libyogacore.so ../lib/libgtest_main.so.1.12.1 ../lib/libgtest.so.1.12.1
/usr/bin/ld: CMakeFiles/yogatests.dir/YGFloatOptionalTest.cpp.o: in function `YGFloatOptionalTest_YGFloatOptionalMax_Test::TestBody()':
YGFloatOptionalTest.cpp:(.text+0xb413): undefined reference to `YGFloatOptionalMax(YGFloatOptional, YGFloatOptional)'
/usr/bin/ld: YGFloatOptionalTest.cpp:(.text+0xb50d): undefined reference to `YGFloatOptionalMax(YGFloatOptional, YGFloatOptional)'
/usr/bin/ld: YGFloatOptionalTest.cpp:(.text+0xb5f8): undefined reference to `YGFloatOptionalMax(YGFloatOptional, YGFloatOptional)'
/usr/bin/ld: YGFloatOptionalTest.cpp:(.text+0xb6f6): undefined reference to `YGFloatOptionalMax(YGFloatOptional, YGFloatOptional)'
/usr/bin/ld: YGFloatOptionalTest.cpp:(.text+0xb81d): undefined reference to `YGFloatOptionalMax(YGFloatOptional, YGFloatOptional)'
collect2: error: ld returned 1 exit status
make[2]: *** [tests/CMakeFiles/yogatests.dir/build.make:887: tests/yogatests] Error 1
make[2]: Leaving directory '/home/sstarr/Downloads/yoga-2.0.0/build'
make[1]: *** [CMakeFiles/Makefile2:218: tests/CMakeFiles/yogatests.dir/all] Error 2
make[1]: Leaving directory '/home/sstarr/Downloads/yoga-2.0.0/build'
make: *** [Makefile:139: all] Error 2
[sstarr@desktop-59bitp3 build]$ make VERBOSE=1
|
I found the following entry in the shared library: 0000000000006bd0 t _Z18YGFloatOptionalMax15YGFloatOptionalS_ by executing nm libyogacore.so > shared_symbols.txt. According to the documentation for the nm command, the t indicates that this symbol is in the text (code) section of the shared library and has local linkage. This means that the symbol is not visible outside the shared library itself, explaining the undefined reference error I encountered when linking against it in yogatests. |
I found the problem in the Utils.h file on line 72. I changed this code: YGFloatOptional YGFloatOptionalMax(
const YGFloatOptional op1,
const YGFloatOptional op2); to: __attribute__((visibility("default"))) YGFloatOptional YGFloatOptionalMax(
const YGFloatOptional op1,
const YGFloatOptional op2); Now everything builds correctly. I would really appreciate it if the Yoga developers could conduct their testing, and possibly include an option to build a shared library in a future release. |
I just realized we are neighbors; I am in Bremerton, WA. ;) |
I should also note that what I did, I believe, only works when building using the GCC compiler, maybe LLVM, but I'm not sure. A solution that works for all supported compilers would probably look different than what I did above. When I have time, I'll look into Windows and MacOS (Intel), but mobile and Apple Silicon are beyond my capabilities. But the above at-least works on Linux. Utils.h // Static build regardless should work fine.
#if defined(__GNUC__) // Shared build using gcc will work.
__attribute__((visibility("default"))) YGFloatOptional YGFloatOptionalMax(
const YGFloatOptional op1,
const YGFloatOptional op2);
#else
// Shared build using any other compiler might fail
YGFloatOptional YGFloatOptionalMax(
const YGFloatOptional op1,
const YGFloatOptional op2);
#endif |
There are macros like |
As far as I can tell from scanning the code base, there is no YG_EXPORT already defined, so it would need to be created. Regarding the decision to keep the GTest binary statically linked, I completely disagree. The simple fact is that it doesn't matter either way because GTest isn't getting deployed to the end user, and it serves no other purpose outside of testing the API. |
Oh, it looks like the export macros are The downside of dynamically linking GTest, apart from just the added build config, is that it means anything the UT consumes must be exported from Yoga. This means we need to expose functions in the export table, that were previously considered private. Though if there aren't too many extra exports, and they are safe to be public, I think we could add them. |
Thanks for pointing that out. It's crazy that I missed YGMacros.h and ... #ifdef _WINDLL
#define WIN_EXPORT __declspec(dllexport)
#else
#define WIN_EXPORT
#endif
#ifndef YOGA_EXPORT
#ifdef _MSC_VER
#define YOGA_EXPORT
#else
#define YOGA_EXPORT __attribute__((visibility("default")))
#endif
#endif |
I made the following modification to Utils.h, which resulted in everything functioning correctly on Linux and MacOS. However, when attempting to build the shared library on Windows 10 using CMake and Visual Studio 2022, an error arises during the yogatest building stage. Utils.h #if defined(_WINDLL)
#define EXPORT WIN_EXPORT
#else
#define EXPORT YOGA_EXPORT
#endif
EXPORT YGFloatOptional YGFloatOptionalMax(
const YGFloatOptional op1,
const YGFloatOptional op2); Target Link:
7> CompactValueTest.obj : error LNK2001: unresolved external symbol YGValueAuto
7> CompactValueTest.obj : error LNK2001: unresolved external symbol YGValueUndefined
7> EventsTest.obj : error LNK2019: unresolved external symbol YGNodeSetBaselineFunc referenced in function "private: virtual void __cdecl facebook::yoga::test::EventTest_baseline_functions_get_wrapped_Test::TestBody(void)" (?TestBody@EventTest_baseline_functions_get_wrapped_Test@test@yoga@facebook@@EEAAXXZ)
7> YGAlignBaselineTest.obj : error LNK2001: unresolved external symbol YGNodeSetBaselineFunc
7> YGNodeCallbackTest.obj : error LNK2001: unresolved external symbol "public: void __cdecl YGNode::setMeasureFunc(struct YGSize (__cdecl*)(struct YGNode *,float,enum YGMeasureMode,float,enum YGMeasureMode))" (?setMeasureFunc@YGNode@@QEAAXP6A?AUYGSize@@PEAU1@MW4YGMeasureMode@@M1@Z@Z)
7> YGRoundingMeasureFuncTest.obj : error LNK2001: unresolved external symbol "public: void __cdecl YGNode::setMeasureFunc(struct YGSize (__cdecl*)(struct YGNode *,float,enum YGMeasureMode,float,enum YGMeasureMode))" (?setMeasureFunc@YGNode@@QEAAXP6A?AUYGSize@@PEAU1@MW4YGMeasureMode@@M1@Z@Z)
7> YGAspectRatioTest.obj : error LNK2001: unresolved external symbol "public: void __cdecl YGNode::setMeasureFunc(struct YGSize (__cdecl*)(struct YGNode *,float,enum YGMeasureMode,float,enum YGMeasureMode))" (?setMeasureFunc@YGNode@@QEAAXP6A?AUYGSize@@PEAU1@MW4YGMeasureMode@@M1@Z@Z)
7> YGMeasureCacheTest.obj : error LNK2001: unresolved external symbol "public: void __cdecl YGNode::setMeasureFunc(struct YGSize (__cdecl*)(struct YGNode *,float,enum YGMeasureMode,float,enum YGMeasureMode))" (?setMeasureFunc@YGNode@@QEAAXP6A?AUYGSize@@PEAU1@MW4YGMeasureMode@@M1@Z@Z)
7> YGMeasureModeTest.obj : error LNK2001: unresolved external symbol "public: void __cdecl YGNode::setMeasureFunc(struct YGSize (__cdecl*)(struct YGNode *,float,enum YGMeasureMode,float,enum YGMeasureMode))" (?setMeasureFunc@YGNode@@QEAAXP6A?AUYGSize@@PEAU1@MW4YGMeasureMode@@M1@Z@Z)
7> YGMeasureTest.obj : error LNK2001: unresolved external symbol "public: void __cdecl YGNode::setMeasureFunc(struct YGSize (__cdecl*)(struct YGNode *,float,enum YGMeasureMode,float,enum YGMeasureMode))" (?setMeasureFunc@YGNode@@QEAAXP6A?AUYGSize@@PEAU1@MW4YGMeasureMode@@M1@Z@Z)
7> YGDirtiedTest.obj : error LNK2019: unresolved external symbol "public: void __cdecl YGNode::setDirty(bool)" (?setDirty@YGNode@@QEAAX_N@Z) referenced in function "private: virtual void __cdecl YogaTest_dirtied_Test::TestBody(void)" (?TestBody@YogaTest_dirtied_Test@@EEAAXXZ)
7> YGDirtiedTest.obj : error LNK2019: unresolved external symbol "public: void __cdecl YGNode::markDirtyAndPropagate(void)" (?markDirtyAndPropagate@YGNode@@QEAAXXZ) referenced in function "private: virtual void __cdecl YogaTest_dirtied_propagation_Test::TestBody(void)" (?TestBody@YogaTest_dirtied_propagation_Test@@EEAAXXZ)
7> YGLoggerTest.obj : error LNK2019: unresolved external symbol YGConfigSetPrintTreeFlag referenced in function "private: virtual void __cdecl YogaTest_config_print_tree_enabled_Test::TestBody(void)" (?TestBody@YogaTest_config_print_tree_enabled_Test@@EEAAXXZ)
7> YGNodeCallbackTest.obj : error LNK2019: unresolved external symbol "public: __cdecl YGNode::YGNode(struct YGConfig * const)" (??0YGNode@@QEAA@QEAUYGConfig@@@Z) referenced in function "public: __cdecl YGNode::YGNode(void)" (??0YGNode@@QEAA@XZ)
7> YGConfigTest.obj : error LNK2001: unresolved external symbol "public: __cdecl YGNode::YGNode(struct YGConfig * const)" (??0YGNode@@QEAA@QEAUYGConfig@@@Z)
7> YGNodeCallbackTest.obj : error LNK2019: unresolved external symbol "public: struct YGSize __cdecl YGNode::measure(float,enum YGMeasureMode,float,enum YGMeasureMode,void *)" (?measure@YGNode@@QEAA?AUYGSize@@MW4YGMeasureMode@@M0PEAX@Z) referenced in function "private: virtual void __cdecl YGNode_measure_with_measure_fn_Test::TestBody(void)" (?TestBody@YGNode_measure_with_measure_fn_Test@@EEAAXXZ)
7> YGNodeCallbackTest.obj : error LNK2019: unresolved external symbol "public: float __cdecl YGNode::baseline(float,float,void *)" (?baseline@YGNode@@QEAAMMMPEAX@Z) referenced in function "private: virtual void __cdecl YGNode_baseline_with_baseline_fn_Test::TestBody(void)" (?TestBody@YGNode_baseline_with_baseline_fn_Test@@EEAAXXZ)
7> YGNodeCallbackTest.obj : error LNK2019: unresolved external symbol "public: void __cdecl YGNode::setMeasureFunc(struct YGSize (__cdecl*)(struct YGNode *,float,enum YGMeasureMode,float,enum YGMeasureMode,void *))" (?setMeasureFunc@YGNode@@QEAAXP6A?AUYGSize@@PEAU1@MW4YGMeasureMode@@M1PEAX@Z@Z) referenced in function "private: virtual void __cdecl YGNode_measure_with_context_measure_fn_Test::TestBody(void)" (?TestBody@YGNode_measure_with_context_measure_fn_Test@@EEAAXXZ)
7> YGConfigTest.obj : error LNK2019: unresolved external symbol "public: void __cdecl YGConfig::setCloneNodeCallback(struct YGNode * (__cdecl*)(struct YGNode *,struct YGNode *,int))" (?setCloneNodeCallback@YGConfig@@QEAAXP6APEAUYGNode@@PEAU2@0H@Z@Z) referenced in function "private: virtual void __cdecl ConfigCloningTest_uses_values_provided_by_cloning_callback_Test::TestBody(void)" (?TestBody@ConfigCloningTest_uses_values_provided_by_cloning_callback_Test@@EEAAXXZ)
7> YGConfigTest.obj : error LNK2019: unresolved external symbol "public: void __cdecl YGConfig::setCloneNodeCallback(struct YGNode * (__cdecl*)(struct YGNode *,struct YGNode *,int,void *))" (?setCloneNodeCallback@YGConfig@@QEAAXP6APEAUYGNode@@PEAU2@0HPEAX@Z@Z) referenced in function "private: virtual void __cdecl ConfigCloningTest_can_clone_with_context_Test::TestBody(void)" (?TestBody@ConfigCloningTest_can_clone_with_context_Test@@EEAAXXZ)
7> YGConfigTest.obj : error LNK2019: unresolved external symbol "public: struct YGNode * __cdecl YGConfig::cloneNode(struct YGNode *,struct YGNode *,int,void *)const " (?cloneNode@YGConfig@@QEBAPEAUYGNode@@PEAU2@0HPEAX@Z) referenced in function "private: virtual void __cdecl ConfigCloningTest_uses_values_provided_by_cloning_callback_Test::TestBody(void)" (?TestBody@ConfigCloningTest_uses_values_provided_by_cloning_callback_Test@@EEAAXXZ)
7> TestUtil.obj : error LNK2019: unresolved external symbol "public: static void __cdecl facebook::yoga::Event::reset(void)" (?reset@Event@yoga@facebook@@SAXXZ) referenced in function "public: static int __cdecl facebook::yoga::test::TestUtil::stopCountingNodes(void)" (?stopCountingNodes@TestUtil@test@yoga@facebook@@SAHXZ)
7> TestUtil.obj : error LNK2019: unresolved external symbol "public: static void __cdecl facebook::yoga::Event::subscribe(class std::function<void __cdecl(struct YGNode const &,enum facebook::yoga::Event::Type,class facebook::yoga::Event::Data)> &&)" (?subscribe@Event@yoga@facebook@@SAX$$QEAV?$function@$$A6AXAEBUYGNode@@W4Type@Event@yoga@facebook@@VData@345@@Z@std@@@Z) referenced in function "public: static void __cdecl facebook::yoga::test::TestUtil::startCountingNodes(void)" (?startCountingNodes@TestUtil@test@yoga@facebook@@SAXXZ)
7> C:\Users\steve\Desktop\SquidFX\yoga\build\tests\Debug\yogatests.exe : fatal error LNK1120: 16 unresolved externals
7>Done building target "Link" in project "yogatests.vcxproj" -- FAILED.
7>
7>Done building project "yogatests.vcxproj" -- FAILED.
7>
7>Build FAILED.
7>
7>CompactValueTest.obj : error LNK2001: unresolved external symbol YGValueAuto
7>CompactValueTest.obj : error LNK2001: unresolved external symbol YGValueUndefined
7>EventsTest.obj : error LNK2019: unresolved external symbol YGNodeSetBaselineFunc referenced in function "private: virtual void __cdecl facebook::yoga::test::EventTest_baseline_functions_get_wrapped_Test::TestBody(void)" (?TestBody@EventTest_baseline_functions_get_wrapped_Test@test@yoga@facebook@@EEAAXXZ)
7>YGAlignBaselineTest.obj : error LNK2001: unresolved external symbol YGNodeSetBaselineFunc
7>YGNodeCallbackTest.obj : error LNK2001: unresolved external symbol "public: void __cdecl YGNode::setMeasureFunc(struct YGSize (__cdecl*)(struct YGNode *,float,enum YGMeasureMode,float,enum YGMeasureMode))" (?setMeasureFunc@YGNode@@QEAAXP6A?AUYGSize@@PEAU1@MW4YGMeasureMode@@M1@Z@Z)
7>YGRoundingMeasureFuncTest.obj : error LNK2001: unresolved external symbol "public: void __cdecl YGNode::setMeasureFunc(struct YGSize (__cdecl*)(struct YGNode *,float,enum YGMeasureMode,float,enum YGMeasureMode))" (?setMeasureFunc@YGNode@@QEAAXP6A?AUYGSize@@PEAU1@MW4YGMeasureMode@@M1@Z@Z)
7>YGAspectRatioTest.obj : error LNK2001: unresolved external symbol "public: void __cdecl YGNode::setMeasureFunc(struct YGSize (__cdecl*)(struct YGNode *,float,enum YGMeasureMode,float,enum YGMeasureMode))" (?setMeasureFunc@YGNode@@QEAAXP6A?AUYGSize@@PEAU1@MW4YGMeasureMode@@M1@Z@Z)
7>YGMeasureCacheTest.obj : error LNK2001: unresolved external symbol "public: void __cdecl YGNode::setMeasureFunc(struct YGSize (__cdecl*)(struct YGNode *,float,enum YGMeasureMode,float,enum YGMeasureMode))" (?setMeasureFunc@YGNode@@QEAAXP6A?AUYGSize@@PEAU1@MW4YGMeasureMode@@M1@Z@Z)
7>YGMeasureModeTest.obj : error LNK2001: unresolved external symbol "public: void __cdecl YGNode::setMeasureFunc(struct YGSize (__cdecl*)(struct YGNode *,float,enum YGMeasureMode,float,enum YGMeasureMode))" (?setMeasureFunc@YGNode@@QEAAXP6A?AUYGSize@@PEAU1@MW4YGMeasureMode@@M1@Z@Z)
7>YGMeasureTest.obj : error LNK2001: unresolved external symbol "public: void __cdecl YGNode::setMeasureFunc(struct YGSize (__cdecl*)(struct YGNode *,float,enum YGMeasureMode,float,enum YGMeasureMode))" (?setMeasureFunc@YGNode@@QEAAXP6A?AUYGSize@@PEAU1@MW4YGMeasureMode@@M1@Z@Z)
7>YGDirtiedTest.obj : error LNK2019: unresolved external symbol "public: void __cdecl YGNode::setDirty(bool)" (?setDirty@YGNode@@QEAAX_N@Z) referenced in function "private: virtual void __cdecl YogaTest_dirtied_Test::TestBody(void)" (?TestBody@YogaTest_dirtied_Test@@EEAAXXZ)
7>YGDirtiedTest.obj : error LNK2019: unresolved external symbol "public: void __cdecl YGNode::markDirtyAndPropagate(void)" (?markDirtyAndPropagate@YGNode@@QEAAXXZ) referenced in function "private: virtual void __cdecl YogaTest_dirtied_propagation_Test::TestBody(void)" (?TestBody@YogaTest_dirtied_propagation_Test@@EEAAXXZ)
7>YGLoggerTest.obj : error LNK2019: unresolved external symbol YGConfigSetPrintTreeFlag referenced in function "private: virtual void __cdecl YogaTest_config_print_tree_enabled_Test::TestBody(void)" (?TestBody@YogaTest_config_print_tree_enabled_Test@@EEAAXXZ)
7>YGNodeCallbackTest.obj : error LNK2019: unresolved external symbol "public: __cdecl YGNode::YGNode(struct YGConfig * const)" (??0YGNode@@QEAA@QEAUYGConfig@@@Z) referenced in function "public: __cdecl YGNode::YGNode(void)" (??0YGNode@@QEAA@XZ)
7>YGConfigTest.obj : error LNK2001: unresolved external symbol "public: __cdecl YGNode::YGNode(struct YGConfig * const)" (??0YGNode@@QEAA@QEAUYGConfig@@@Z)
7>YGNodeCallbackTest.obj : error LNK2019: unresolved external symbol "public: struct YGSize __cdecl YGNode::measure(float,enum YGMeasureMode,float,enum YGMeasureMode,void *)" (?measure@YGNode@@QEAA?AUYGSize@@MW4YGMeasureMode@@M0PEAX@Z) referenced in function "private: virtual void __cdecl YGNode_measure_with_measure_fn_Test::TestBody(void)" (?TestBody@YGNode_measure_with_measure_fn_Test@@EEAAXXZ)
7>YGNodeCallbackTest.obj : error LNK2019: unresolved external symbol "public: float __cdecl YGNode::baseline(float,float,void *)" (?baseline@YGNode@@QEAAMMMPEAX@Z) referenced in function "private: virtual void __cdecl YGNode_baseline_with_baseline_fn_Test::TestBody(void)" (?TestBody@YGNode_baseline_with_baseline_fn_Test@@EEAAXXZ)
7>YGNodeCallbackTest.obj : error LNK2019: unresolved external symbol "public: void __cdecl YGNode::setMeasureFunc(struct YGSize (__cdecl*)(struct YGNode *,float,enum YGMeasureMode,float,enum YGMeasureMode,void *))" (?setMeasureFunc@YGNode@@QEAAXP6A?AUYGSize@@PEAU1@MW4YGMeasureMode@@M1PEAX@Z@Z) referenced in function "private: virtual void __cdecl YGNode_measure_with_context_measure_fn_Test::TestBody(void)" (?TestBody@YGNode_measure_with_context_measure_fn_Test@@EEAAXXZ)
7>YGConfigTest.obj : error LNK2019: unresolved external symbol "public: void __cdecl YGConfig::setCloneNodeCallback(struct YGNode * (__cdecl*)(struct YGNode *,struct YGNode *,int))" (?setCloneNodeCallback@YGConfig@@QEAAXP6APEAUYGNode@@PEAU2@0H@Z@Z) referenced in function "private: virtual void __cdecl ConfigCloningTest_uses_values_provided_by_cloning_callback_Test::TestBody(void)" (?TestBody@ConfigCloningTest_uses_values_provided_by_cloning_callback_Test@@EEAAXXZ)
7>YGConfigTest.obj : error LNK2019: unresolved external symbol "public: void __cdecl YGConfig::setCloneNodeCallback(struct YGNode * (__cdecl*)(struct YGNode *,struct YGNode *,int,void *))" (?setCloneNodeCallback@YGConfig@@QEAAXP6APEAUYGNode@@PEAU2@0HPEAX@Z@Z) referenced in function "private: virtual void __cdecl ConfigCloningTest_can_clone_with_context_Test::TestBody(void)" (?TestBody@ConfigCloningTest_can_clone_with_context_Test@@EEAAXXZ)
7>YGConfigTest.obj : error LNK2019: unresolved external symbol "public: struct YGNode * __cdecl YGConfig::cloneNode(struct YGNode *,struct YGNode *,int,void *)const " (?cloneNode@YGConfig@@QEBAPEAUYGNode@@PEAU2@0HPEAX@Z) referenced in function "private: virtual void __cdecl ConfigCloningTest_uses_values_provided_by_cloning_callback_Test::TestBody(void)" (?TestBody@ConfigCloningTest_uses_values_provided_by_cloning_callback_Test@@EEAAXXZ)
7>TestUtil.obj : error LNK2019: unresolved external symbol "public: static void __cdecl facebook::yoga::Event::reset(void)" (?reset@Event@yoga@facebook@@SAXXZ) referenced in function "public: static int __cdecl facebook::yoga::test::TestUtil::stopCountingNodes(void)" (?stopCountingNodes@TestUtil@test@yoga@facebook@@SAHXZ)
7>TestUtil.obj : error LNK2019: unresolved external symbol "public: static void __cdecl facebook::yoga::Event::subscribe(class std::function<void __cdecl(struct YGNode const &,enum facebook::yoga::Event::Type,class facebook::yoga::Event::Data)> &&)" (?subscribe@Event@yoga@facebook@@SAX$$QEAV?$function@$$A6AXAEBUYGNode@@W4Type@Event@yoga@facebook@@VData@345@@Z@std@@@Z) referenced in function "public: static void __cdecl facebook::yoga::test::TestUtil::startCountingNodes(void)" (?startCountingNodes@TestUtil@test@yoga@facebook@@SAXXZ)
7>C:\Users\steve\Desktop\SquidFX\yoga\build\tests\Debug\yogatests.exe : fatal error LNK1120: 16 unresolved externals
7> 0 Warning(s)
7> 24 Error(s)
7>
7>Time Elapsed 00:00:50.54
8>------ Build started: Project: ALL_BUILD, Configuration: Debug x64 ------
8>Build started 8/8/2023 6:21:45 PM.
8>Target ResolveProjectReferences:
8> Target GetTargetPathWithTargetPlatformMoniker:
8>Target PrepareForBuild:
8> Creating directory "x64\Debug\ALL_BUILD\ALL_BUILD.tlog\".
8>Target InitializeBuildStatus:
8> Creating "x64\Debug\ALL_BUILD\ALL_BUILD.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
8>Target CustomBuild:
8> Building Custom Rule C:/Users/steve/Desktop/SquidFX/yoga/CMakeLists.txt
8>Target GetReferencedVCProjectsInfo:
8> Target DisableProjectReferenceRecursionForClInputs:
8>Target FinalizeBuildStatus:
8> Deleting file "x64\Debug\ALL_BUILD\ALL_BUILD.tlog\unsuccessfulbuild".
8> Touching "x64\Debug\ALL_BUILD\ALL_BUILD.tlog\ALL_BUILD.lastbuildstate".
8>
8>Build succeeded.
8> 0 Warning(s)
8> 0 Error(s)
8>
8>Time Elapsed 00:00:00.16
9>------ Skipped Build: Project: INSTALL, Configuration: Debug x64 ------
9>Project not selected to build for this solution configuration
========== Build: 7 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========
========== Build started at 6:20 PM and took 57.630 seconds ==========
|
|
Hi @NickGerleman, Disclaimer: I am (almost) absolutely a beginner in the JNI/cmake/C++, every action described below was an act of monkey typing, cope-paste and googling. My idea is to execute java unit tests with Yoga as a native library. I aim to create a JAR file with an embedded binary that is compatible with Linux. I've attempted to achieve this by running commands from workflow, on a virtual machine running Ubuntu. (It's important to note that I've installed necessary tools such as Ninja, CMake, etc., and the unit tests and benchmarks execute correctly.) For building the binary, I utilized the CMakeLists.txt from the Java directory. I made modifications (basing on I based on v2.0.1, repo was cloned to dir named
Next I run cmake commands:
getting some warning (more than I paste here, but all of them looks similar):
But I got my
App blows up (surprise):
So, I must do something wrong, that's for sure. Maybe there is something extra done by android NDK? Maybe C++ standard is wrong? Please give me some clue. Ps. I also tried the same steps on macos where I got different errors :/ |
Small update. I have find out that my I still have those scary warnings on linux (and compile errors on mac), so if you have any advice about env configuration please tell. |
I need to build Yoga as a shared library so that I can create C# bindings using p/invoke. Below is the updated CMakeLists.txt file for the 'yoga' directory. It includes an option to build Yoga as a shared library. Please note that although it successfully builds Yoga as a working shared library, it still throws an error. I suspect the issue is with yogatest trying to build against the Yoga static library. Any help with working on this would be greatly appreciated.
Error
yoga/CMakeLists.txt
The text was updated successfully, but these errors were encountered: