Skip to content
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

Link problem with MinGW #5575

Open
1 task done
RookieCLY opened this issue Jan 15, 2025 · 2 comments
Open
1 task done

Link problem with MinGW #5575

RookieCLY opened this issue Jan 15, 2025 · 2 comments
Labels
need more info Issue that requires more info from contributor

Comments

@RookieCLY
Copy link

Is there an already existing issue for this?

  • I have searched the existing issues

Expected behavior

I have already compile foonathan_memory, fastcdr and tinyxml2 with MinGW successfully. But there are some problem when I compile the fastdds with MinGW, like "i64 to LL","stat redefined","declspec( dllexport ) to attribute((visibility("default")))"...... I used some special means to solve these problems and finally successfully compiled fastdds, then i got libfastdds.dll and libfastdds.dll.a

Current behavior

But when I use libfastdds.dll and libfastdds.dll.a in my project, there are some thing wrong like
E:/mingw32-14/bin/../lib/gcc/i686-w64-mingw32/14.2.0/../../../../i686-w64-mingw32/bin/ld.exe: CMakeFiles\MBus.dir/objects.a(startlogPubSubTypes.cxx.obj):startlogPubSubTypes.cxx:(.text+0x5cd): undefined reference to eprosima::fastdds::MD5::MD5()'`......
All the symbol from FastDDS which i used in my project was undefined. I tried every import and export combination in fastdds_dll.hpp, "attribute((visibility("default")))" "declspec( dllexport )" "declspec( dllimport )" "null" . But does not work.
Are there some special export config for MinGW in FastDDS?

Steps to reproduce

1:Compile foonathan_memory, fastcdr and tinyxml2 with MinGW.
2:Modify the source code, like modify CMAKE_CXX_FLAGS, modify include in some files, and so on.
3:Use libfastdds.dll.a in your project.

Fast DDS version/commit

FastDDS v3.1.1 master
FastCDR v2.2.5
MinGW v14.2.0
Windows10

Platform/Architecture

Other. Please specify in Additional context section.

Transport layer

Default configuration, UDPv4 & SHM

Additional context

No response

XML configuration file

No response

Relevant log output

No response

Network traffic capture

No response

@RookieCLY RookieCLY added the triage Issue pending classification label Jan 15, 2025
@Javgilavi
Copy link
Contributor

Hi @RookieCLY,

Can you share more details on the errors that you had when compiling fastdds? And what were the "solution means" that you did?

@Javgilavi Javgilavi added need more info Issue that requires more info from contributor and removed triage Issue pending classification labels Jan 15, 2025
@RookieCLY
Copy link
Author

RookieCLY commented Jan 15, 2025

@Javgilavi
Yes, my pleasure. “solution means” can be divided into three parts.
First, warning with little impact. like "unused-parameter" "missing-field-initializers" and so on. I just use command like "-Wno-unused-parameter" to ignore them.
Then, some llibrary error between windows and unix. Added option for "elif defined(MINGW)" to ifdef _WIN32(or _MSC_VER) and else , then fill the MINGW branch, so it can work as same as the _WIN32(or _MSC_VER) branch. For example, in "RobustExclusiveLock.hpp", add "elif defined(MINGW)" to ifdef _MSC_VER and else in the "include" block and "class" block. Then copy the code from "_MSC_VER" block, use the same function "_sopen_s" with <io.h>(MinGW), modify "_SH_DENYRW" to "0x0010", which is not defined in <io.h>(MinGW).
Third, Manually link library, like "target_link_libraries(fastdds PUBLIC ws2_32 mswsock)".

As for the error in this issue, I solved this problem with "declspec( dllexport )" and "-Wno-attributes". So i can use almost all the symbols from libfastdds.dll and libfastdds.dll.a.
Why "almost all"? There are some new problem for "TypeSupport".
When I use TypeSupport(new startlogPubSubType()) to construct a TypeSupport object, i got the error
E:/mingw32-14/bin/../lib/gcc/i686-w64-mingw32/14.2.0/../../../../i686-w64-mingw32/bin/ld.exe: C:\Users\CUILIU~1\AppData\Local\Temp\ccEr7V0I.o:xmsgbus.cxx:(.text$_ZN8eprosima7fastdds3dds11TypeSupportC1EPNS1_13TopicDataTypeE[__ZN8eprosima7fastdds3dds11TypeSupportC1EPNS1_13TopicDataTypeE]+0x20): undefined reference tovtable for eprosima::fastdds::dds::TypeSupport' `
Maybe there are some thing wrong with "class TypeSupport : public std::shared_ptr<TopicDataType>" and MinGW?
By the way, "startlogPubSubType" was generated by fastdds-gen with a idl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more info Issue that requires more info from contributor
Projects
None yet
Development

No branches or pull requests

2 participants