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
Alpine Compile Failed #846
Comments
Perhaps you could find out what the difference is between Alpine Linux and the other Linux distributions on which the build works, and suggest some changes that would make it work? |
OK, I'll try. |
Some of these errors are fixed in the response to #851, which the latest source includes. |
If you try again with the latest 1.3.2 source, we should be closer. |
The FILE and LINE macros are standard C, I don't know why they aren't there. You can build with the NOSTACKTRACE or HIGH_PERFORMANCE compiler definitions which will build without stack tracing, and avoid the need for these macros. That should allow it to build. |
It is not The FILE and LINE macros, because are passed, but not: #define free(x) myfree(FILE, LINE, x) |
Did you try building with the compile definitions I suggested? |
Well I tried it for you. Building with HIGH_PERFORMANCE defined works for me. |
I can confirm that current version (1.3.2) fails to build on musl due to the redefinition of free. It raises the following build failure on buildroot:
Full build log can be found here: http://autobuild.buildroot.org/results/fbe/fbe57a1602fed331ddff3ff3560dce02573816ff/build-end.log I also confirm that building with |
@ffontaine why does it object to the redefinition of free, but not malloc or realloc? As far as I remember, this is the first time this has caused a problem in 14 years. |
In the absence of any other way to fix it, I'm going to add a note to the documentation on building with HIGH_PERFORMANCE if this error is met. |
I tried to investigate this issue. The build failure is raised only by I checked what was different in this file and I found that the build failure could be fixed by adding an include on |
Set PAHO_HIGH_PERFORMANCE to disable free redefiniton as suggested by upstream in eclipse/paho.mqtt.c#846. This will avoid the following build failure on musl: /tmp/instance-1/output-1/host/x86_64-buildroot-linux-musl/sysroot/usr/include/sched.h:80:17: error: expected declaration specifiers or '...' before string constant void free(void *); ^ /tmp/instance-1/output-1/host/x86_64-buildroot-linux-musl/sysroot/usr/include/sched.h:80:17: error: expected declaration specifiers or '...' before numeric constant void free(void *); ^ [ 35%] Building C object src/CMakeFiles/common_obj.dir/Base64.c.o [ 36%] Building C object src/CMakeFiles/common_obj.dir/SHA1.c.o make[3]: *** [src/CMakeFiles/common_obj.dir/build.make:284: src/CMakeFiles/common_obj.dir/MQTTReasonCodes.c.o] Error 1 Fixes: - http://autobuild.buildroot.org/results//fbe57a1602fed331ddff3ff3560dce02573816ff Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
The issue why the build error is only raised for |
Set PAHO_HIGH_PERFORMANCE to disable free redefiniton as suggested by upstream in eclipse/paho.mqtt.c#846. This will avoid the following build failure on musl: /tmp/instance-1/output-1/host/x86_64-buildroot-linux-musl/sysroot/usr/include/sched.h:80:17: error: expected declaration specifiers or '...' before string constant void free(void *); ^ /tmp/instance-1/output-1/host/x86_64-buildroot-linux-musl/sysroot/usr/include/sched.h:80:17: error: expected declaration specifiers or '...' before numeric constant void free(void *); ^ [ 35%] Building C object src/CMakeFiles/common_obj.dir/Base64.c.o [ 36%] Building C object src/CMakeFiles/common_obj.dir/SHA1.c.o make[3]: *** [src/CMakeFiles/common_obj.dir/build.make:284: src/CMakeFiles/common_obj.dir/MQTTReasonCodes.c.o] Error 1 Fixes: - http://autobuild.buildroot.org/results//fbe57a1602fed331ddff3ff3560dce02573816ff Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> Signed-off-by: Peter Korsgaard <peter@korsgaard.com> (cherry picked from commit e446f5a) Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Describe the bug
I compile it in alpine but failed:
/github.com/paho.mqtt.c # make
mkdir -p build/output/samples
mkdir -p build/output/test
echo OSTYPE is Linux
OSTYPE is Linux
mkdir -p build
sed -e "s/@CLIENT_VERSION@/1.3.2/g" -e "s/@BUILD_TIMESTAMP@/Sat Apr 18 11:18:58 UTC 2020/g" src/VersionInfo.h.in > build/VersionInfo.h
cc -g -fPIC -D_GNU_SOURCE -Os -Wall -fvisibility=hidden -Ibuild -DPAHO_MQTT_EXPORTS=1 -o build/output/libpaho-mqtt3c.so.1.3 src/Messages.c src/Tree.c src/MQTTProtocolClient.c src/Base64.c src/SocketBuffer.c src/utf-8.c src/MQTTReasonCodes.c src/StackTrace.c src/Log.c src/MQTTClient.c src/SHA1.c src/MQTTPacket.c src/OsWrapper.c src/Clients.c src/WebSocket.c src/MQTTPersistence.c src/Thread.c src/Socket.c src/MQTTPacketOut.c src/MQTTTime.c src/MQTTPersistenceDefault.c src/MQTTProperties.c src/MQTTProtocolOut.c src/LinkedList.c src/Heap.c -shared -Wl,-init,MQTTClient_init -Wl,--start-group -lpthread -lanl -Wl,--end-group -Wl,-soname,libpaho-mqtt3c.so.1
src/Heap.h:55:24: error: expected declaration specifiers or '...' before string constant
55 | #define free(x) myfree(FILE, LINE, x)
| ^~~~~~~~
src/Heap.h:55:34: error: expected declaration specifiers or '...' before numeric constant
55 | #define free(x) myfree(FILE, LINE, x)
| ^~~~~~~~
In file included from src/StackTrace.c:21:
src/Clients.h:59:18: error: field 'lastTouch' has incomplete type
59 | START_TIME_TYPE lastTouch; /> used for retry and expiry /
| ^~~~~~~~~
src/Clients.h:79:18: error: field 'lastSent' has incomplete type
79 | START_TIME_TYPE lastSent;
| ^~~~~~~~
src/Clients.h:80:18: error: field 'lastReceived' has incomplete type
80 | START_TIME_TYPE lastReceived;
| ^~~~~~~~~~~~
src/Clients.h:81:18: error: field 'lastPing' has incomplete type
81 | START_TIME_TYPE lastPing;
| ^~~~~~~~
src/StackTrace.c: In function 'StackTrace_entry':
src/StackTrace.c:112:34: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
112 | Log_stackTrace(trace_level, 9, (int)my_thread->id, my_thread->current_depth, name, line, NULL);
| ^
src/StackTrace.c: In function 'StackTrace_exit':
src/StackTrace.c:136:36: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
136 | Log_stackTrace(trace_level, 10, (int)my_thread->id, my_thread->current_depth, name, line, NULL);
| ^
src/StackTrace.c:138:36: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
138 | Log_stackTrace(trace_level, 11, (int)my_thread->id, my_thread->current_depth, name, line, (int)rc);
| ^
In file included from src/Clients.c:24:
src/Clients.h:59:18: error: field 'lastTouch' has incomplete type
59 | START_TIME_TYPE lastTouch; /> used for retry and expiry */
| ^~~~~~~~~
src/Clients.h:79:18: error: field 'lastSent' has incomplete type
79 | START_TIME_TYPE lastSent;
| ^~~~~~~~
src/Clients.h:80:18: error: field 'lastReceived' has incomplete type
80 | START_TIME_TYPE lastReceived;
| ^~~~~~~~~~~~
src/Clients.h:81:18: error: field 'lastPing' has incomplete type
81 | START_TIME_TYPE lastPing;
| ^~~~~~~~
In file included from src/WebSocket.h:20,
from src/WebSocket.c:30:
src/Clients.h:59:18: error: field 'lastTouch' has incomplete type
59 | START_TIME_TYPE lastTouch; /> used for retry and expiry */
| ^~~~~~~~~
src/Clients.h:79:18: error: field 'lastSent' has incomplete type
79 | START_TIME_TYPE lastSent;
| ^~~~~~~~
src/Clients.h:80:18: error: field 'lastReceived' has incomplete type
80 | START_TIME_TYPE lastReceived;
| ^~~~~~~~~~~~
src/Clients.h:81:18: error: field 'lastPing' has incomplete type
81 | START_TIME_TYPE lastPing;
| ^~~~~~~~
In file included from src/MQTTPersistence.h:27,
from src/MQTTPersistence.c:29:
src/Clients.h:59:18: error: field 'lastTouch' has incomplete type
59 | START_TIME_TYPE lastTouch; /> used for retry and expiry */
| ^~~~~~~~~
src/Clients.h:79:18: error: field 'lastSent' has incomplete type
79 | START_TIME_TYPE lastSent;
| ^~~~~~~~
src/Clients.h:80:18: error: field 'lastReceived' has incomplete type
80 | START_TIME_TYPE lastReceived;
| ^~~~~~~~~~~~
src/Clients.h:81:18: error: field 'lastPing' has incomplete type
81 | START_TIME_TYPE lastPing;
| ^~~~~~~~
make: *** [Makefile:254: build/output/libpaho-mqtt3c.so.1.3] Error 1
/github.com/paho.mqtt.c #
To Reproduce
Fresh alpine:latest docker image.
apk add openssl-dev
make
** Environment (please complete the following information):**
The text was updated successfully, but these errors were encountered: