How to generate C/C++ Shared Library for Linux 32-bit target from Linux 64-bit Host?

조회 수: 9 (최근 30일)
Hi,
I am working in a Matlab design and I have intend to use the Matlab Coder for Linux 32 bits target. However, the Matlab Coder provide support only to generate shared library for Linux 64 bits target. Then I made a workaround to generate shared library via Matlab Coder with the following changes (adding –m32 flag) in makefile (*.mk), such as:
- CFLAGS = -m32 -c $(ANSI_OPTS) -fPIC -O0 $(CDEBUG)
- CPPFLAGS = -m32 -c $(CPP_ANSI_OPTS) -fPIC -O0 $(CPPDEBUG)
- CPP_LDFLAGS = -m32 -Wl,-rpath,"$(MATLAB_ARCH_BIN)",-L"$(MATLAB_ARCH_BIN)" $(CPPLDDEBUG)
- CPP_SHAREDLIB_LDFLAGS = -m32 -shared -Wl,-rpath,"$(MATLAB_ARCH_BIN)",-L"$(MATLAB_ARCH_BIN)" -Wl,--no-undefined $(CPPLDDEBUG)
I am wondering, if I can change the makefile in order to cross-compile for Linux 32 bits target and why the Matlab does not provide by default this setting? And, what can I lose (performance, possible problems, etc.) with it workaround?
Below it follows my environment settings:
- Host: Linux 64 bits (Debian 8.3), kernel 3.16.0
- Matlab: 9.0.0.341360 (R2016A)
- Matlab Coder: Version 3.1 (R2016a)
- Target: Linux 32 bits, kernel 2.6.32
Thank in advance,
Bruno

답변 (1개)

Raghu Boggavarapu
Raghu Boggavarapu 2021년 11월 26일
You can use coder.updateBuildInfo to add custom compiler flags. In your case its '-m32' .

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by