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

Android NDK compile error #1261

Closed
CRC32EX opened this issue Apr 12, 2021 · 1 comment
Closed

Android NDK compile error #1261

CRC32EX opened this issue Apr 12, 2021 · 1 comment

Comments

@CRC32EX
Copy link

CRC32EX commented Apr 12, 2021

Steps to reproduce this issue

1. clone & build my project

git clone https://github.com/CRC32EX/AndroidWebServer
cd AndroidWebServer
ndk-build

2. Error

$ ndk-build
[arm64-v8a] Executable     : AndroidWebServer
./obj/local/arm64-v8a/objs/AndroidWebServer/__/main.o: In function `main':
C:\Users\user01\Desktop\AndroidTest/jni/../main.cpp:17: undefined reference to `mg_mgr_init(mg_mgr*)'
C:\Users\user01\Desktop\AndroidTest/jni/../main.cpp:20: undefined reference to `mg_http_listen(mg_mgr*, char const*, void (*)(mg_connection*, int, void*, void*), void*)'
C:\Users\user01\Desktop\AndroidTest/jni/../main.cpp:24: undefined reference to `mg_mgr_poll(mg_mgr*, int)'
./obj/local/arm64-v8a/objs/AndroidWebServer/__/main.o: In function `fn(mg_connection*, int, void*, void*)':
C:\Users\user01\Desktop\AndroidTest/jni/../main.cpp:7: undefined reference to `mg_http_match_uri(mg_http_message const*, char const*)'
C:\Users\user01\Desktop\AndroidTest/jni/../main.cpp:8: undefined reference to `mg_http_reply(mg_connection*, int, char const*, char const*, ...)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [C:/Android/ndk/21.1.6352462/build//../build/core/build-binary.mk:738: obj/local/arm64-v8a/AndroidWebServer] Error 1

Possible solution

  • I can compile with C code only.
    But I want use mongoose with C++.
main.cpp -> main.c

Environment

  • Windows 10 64bit 20H2
  • mongoose 7.3
  • Android NDK
$ ndk-build --version
GNU Make 4.2.1
Built for x86_64-w64-mingw32
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
@CRC32EX
Copy link
Author

CRC32EX commented Apr 12, 2021

Solved.
Use extern "C".

main.cpp

extern "C" {
#include "mongoose.h"
}

@CRC32EX CRC32EX closed this as completed Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant