-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Description / Steps to reproduce the issue
There is a issue on build program using qt6.I installed msys2 on windows10, and setup mingw64 tools-chain and mingw_x86 icu. But when i tried to build a qt6 program with including <unicode/ucsdet.h>. There's some error on building program. What's wrong with it?
Expected behavior
// my code for testing icu working properly
#include "icu_lib.h"
#include <unicode/ucsdet.h>
#include <iostream>
Icu_lib::Icu_lib(QWidget *parent)
: QWidget{parent}
{}
void Icu_lib::runIcu()
{
const char *text = "Hello, 世界!";
char *detected = nullptr;
if (detectTextEncoding(text, strlen(text), &detected)) {
std::cout << "Detected encoding: " << detected << std::endl;
free(detected);
} else {
std::cout << "Failed to detect encoding." << std::endl;
}
return ;
}
bool Icu_lib::detectTextEncoding(const char *data, int32_t len, char **detected)
{
UErrorCode status = U_ZERO_ERROR;
UCharsetDetector *csd = ucsdet_open(&status);
if (U_FAILURE(status)) return false;
ucsdet_setText(csd, data, len, &status);
if (U_FAILURE(status)) return false;
int32_t matchCount = 0;
const UCharsetMatch **csm = ucsdet_detectAll(csd, &matchCount, &status);
if (U_FAILURE(status)) return false;
if (matchCount > 0) {
*detected = strdup(ucsdet_getName(csm[0], &status));
if (U_FAILURE(status)) return false;
}
ucsdet_close(csd);
return true;
}
Actual behavior
C:\Users\WIN10\Documents\icu_test\icu_lib.cpp:-1: error: undefined reference to ucsdet_open_77' :-1: error: C:/Users/WIN10/Documents/icu_test/icu_lib.cpp:32:(.text+0x1a1): undefined reference to
ucsdet_setText_77'
👎 error: C:/Users/WIN10/Documents/icu_test/icu_lib.cpp:36:(.text+0x1dc): undefined reference to ucsdet_detectAll_77' :-1: error: C:/Users/WIN10/Documents/icu_test/icu_lib.cpp:40:(.text+0x214): undefined reference to
ucsdet_getName_77'
👎 error: C:/Users/WIN10/Documents/icu_test/icu_lib.cpp:44:(.text+0x24c): undefined reference to `ucsdet_close_77'
👎 error: collect2.exe: error: ld returned 1 exit status
👎 error: ninja: build stopped: subcommand failed.
Verification
- I have verified that my MSYS2 is up-to-date before submitting the report (see https://www.msys2.org/docs/updating/)
Windows Version
win10
MINGW environments affected
- MINGW64
- MINGW32
- UCRT64
- CLANG64
- CLANGARM64
Are you willing to submit a PR?
No response