taosdata / TDengine

High-performance, scalable time-series database designed for Industrial IoT (IIoT) scenarios
https://tdengine.com
GNU Affero General Public License v3.0
23.24k stars 4.84k forks source link

macos compile. #11248

Closed ccwxl closed 2 years ago

ccwxl commented 2 years ago

Bug Description [ 56%] Built target query [ 56%] Building C object src/client/CMakeFiles/taos_static.dir/src/TSDBJNIConnector.c.o [ 56%] Building C object src/client/CMakeFiles/taos_static.dir/src/dataxJniConnection.c.o [ 56%] Building C object src/client/CMakeFiles/taos_static.dir/src/tscAsync.c.o [ 57%] Building C object src/client/CMakeFiles/taos_static.dir/src/tscGlobalmerge.c.o [ 57%] Building C object src/client/CMakeFiles/taos_static.dir/src/tscLocal.c.o [ 57%] Building C object src/client/CMakeFiles/taos_static.dir/src/tscParseInsert.c.o [ 57%] Building C object src/client/CMakeFiles/taos_static.dir/src/tscParseLineProtocol.c.o [ 58%] Building C object src/client/CMakeFiles/taos_static.dir/src/tscParseOpenTSDB.c.o [ 58%] Building C object src/client/CMakeFiles/taos_static.dir/src/tscPrepare.c.o [ 58%] Building C object src/client/CMakeFiles/taos_static.dir/src/tscProfile.c.o [ 58%] Building C object src/client/CMakeFiles/taos_static.dir/src/tscSQLParser.c.o /Users/wxl/Desktop/TDengine/src/client/src/tscSQLParser.c:3015:17: error: variable 'numOfFields' set but not used [-Werror,-Wunused-but-set-variable] int32_t numOfFields = 0; ^ 1 error generated. make[2]: [src/client/CMakeFiles/taos_static.dir/src/tscSQLParser.c.o] Error 1 make[1]: [src/client/CMakeFiles/taos_static.dir/all] Error 2 make: *** [all] Error 2

编译时报错, 分支: ver-2.4.0.14

ccwxl commented 2 years ago

[ 97%] Building C object src/connector/odbc/examples/c/CMakeFiles/tcodbc.dir/main.c.o /Users/wxl/Desktop/TDengine/src/connector/odbc/examples/c/main.c:644:13: error: variable 'count' set but not used [-Werror,-Wunused-but-set-variable] size_t count = 0; ^ 1 error generated. make[2]: [src/connector/odbc/examples/c/CMakeFiles/tcodbc.dir/main.c.o] Error 1 make[1]: [src/connector/odbc/examples/c/CMakeFiles/tcodbc.dir/all] Error 2

same error.

sangshuduo commented 2 years ago

什么分支?commit id 是多少?clang 是什么版本?最近刚修复了一个类似的问题,用最新 develop 分支应该没有这个问题了

ccwxl commented 2 years ago
ccwxl commented 2 years ago

public class TestTDengine { private static String host1 = "127.0.0.1"; private static String host = "192.168.8.80"; private static final String dbName = "iotdata"; private static final String user = "root"; private static final String password = "taosdata"; private Connection connection;

public static void main(String[] args) throws SQLException {
    TestTDengine testTDengine = new TestTDengine();
    testTDengine.init();
    testTDengine.userdb();
    testTDengine.testJni();
}

private void userdb() {
    String sql = "use " + dbName;
    exuete(sql);
}

private void testJni() throws SQLException {
    String line = "dd_A001_1009,id=AA3043,protocol=A001 generateTs=1648757500175i,isstaticvoltage=1i,receiveTs=1648757500175i,voltage=26.3 1648757500175";
    SchemalessWriter schemalessWriter = new SchemalessWriter(connection);
    schemalessWriter.write(new String[]{line}, SchemalessProtocolType.LINE, SchemalessTimestampType.MILLI_SECONDS);
}

private void init() {
    final String url = "jdbc:TAOS://" + host + ":6030/?user=" + user + "&password=" + password;
    // get connection
    try {
        Properties properties = new Properties();
        properties.setProperty("charset", "UTF-8");
        properties.setProperty("locale", "en_US.UTF-8");
        //非常重要
        properties.setProperty("smlChildTableName", "id");
        properties.setProperty("smlTagNullName", "protocol");
        properties.setProperty("timezone", "UTC-8");
        System.out.println("get connection starting...");
        connection = DriverManager.getConnection(url, properties);
        connection.setCatalog("iotdata");
        if (connection != null) {
            System.out.println("[ OK ] Connection established.");
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}

private void exuete(String sql) {
    long start = System.currentTimeMillis();
    try (Statement statement = connection.createStatement()) {
        boolean execute = statement.execute(sql);
        long end = System.currentTimeMillis();
        printSql(sql, true, (end - start));
    } catch (SQLException e) {
        long end = System.currentTimeMillis();
        printSql(sql, false, (end - start));
        e.printStackTrace();
    }
}

private void printSql(String sql, boolean succeed, long cost) {
    System.out.println("[ " + (succeed ? "OK" : "ERROR!") + " ] time cost: " + cost + " ms, execute statement ====> " + sql);
}

}

- 报错

Connected to the target VM, address: '127.0.0.1:54148', transport: 'socket' get connection starting... [ OK ] Connection established. [ OK ] time cost: 9 ms, execute statement ====> use iotdata Exception in thread "main" java.sql.SQLException: TDengine ERROR (2350): failed to insertLines at com.taosdata.jdbc.TSDBError.createSQLException(TSDBError.java:76) at com.taosdata.jdbc.TSDBJNIConnector.insertLines(TSDBJNIConnector.java:366) at com.taosdata.jdbc.SchemalessWriter.write(SchemalessWriter.java:35) at cn.nvriot.timeseries.tdengine.TestTDengine.testJni(TestTDengine.java:42) at cn.nvriot.timeseries.tdengine.TestTDengine.main(TestTDengine.java:31) Disconnected from the target VM, address: '127.0.0.1:54148', transport: 'socket'

- 服务端表自动建好了但数据没有写入进去.

taos> show stables; name | created_time | columns | tags | tables |

dd_A001_1009 | 2022-04-06 13:07:55.172 | 5 | 3 | 1 | Query OK, 1 row(s) in set (0.001085s)

taos> show tables; table_name | created_time | columns | stable_name | uid | tid | vgId |

AA3043 | 2022-04-06 13:32:37.308 | 5 | dd_A001_1009 | 10696049144601636 | 1 | 38 | Query OK, 1 row(s) in set (0.006999s)

taos> select * from AA3043; Query OK, 0 row(s) in set (0.002180s)


- 写入到本地macos 的服务端是没有问题的.
sangshuduo commented 2 years ago

mac 平台还没有正式支持,可能有没有发现的 bug

ccwxl commented 2 years ago
100apps commented 2 years ago

→ sw_vers ProductName: macOS ProductVersion: 12.2.1 BuildVersion: 21D62

→ gcc --version Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/c++/4.2.1 Apple clang version 13.0.0 (clang-1300.0.27.3) Target: x86_64-apple-darwin21.3.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

→ clang --version Apple clang version 13.0.0 (clang-1300.0.27.3) Target: x86_64-apple-darwin21.3.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

→ mkdir debug && cd debug cmake .. && cmake --build . -- The CXX compiler identification is AppleClang 13.0.0.13000027 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Community directory: /data/pro/tsdb/TDengine -- The C compiler identification is AppleClang 13.0.0.13000027 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- build with TSZ enabled -- The current platform is Darwin 64-bit -- The current platform x86_64 is detected -- The current platform is x86 -- Set CPUTYPE to x86 -- platform arch:i386 -- The user specified osType is unknown: Will not build taos_tools! Enable lua -- darwin64 is defined -- CMAKE_CXX_COMPILER_ID: Clang -- Project source directory: /data/pro/tsdb/TDengine -- Project binary files output path: /data/pro/tsdb/TDengine/debug -- Project executable files output path: /data/pro/tsdb/TDengine/debug/build/bin -- Project library files output path: /data/pro/tsdb/TDengine/debug/build/lib -- MVN is installed and JDBC will be compiled -- Build Debug Version as default -- git log result:c0ecbe2aded61e950e5ce84da8c0fc8158431d7e

-- git log result:c0ecbe2aded61e950e5ce84da8c0fc8158431d7e

-- ============= compile version parameter information start ============= -- ver number:2.4.0.0 -- compatible ver number:2.0.0.0 -- community commit id:c0ecbe2aded61e950e5ce84da8c0fc8158431d7e -- internal commit id:c0ecbe2aded61e950e5ce84da8c0fc8158431d7e -- build date:2022-04-17 22:49:25 -- ver type:stable -- ver cpu:x32 -- os type:Linux -- ============= compile version parameter information end ============= CMake Deprecation Warning at deps/TSZ/CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.

Update the VERSION argument value or use a ... suffix to tell CMake that the project does not need compatibility with older versions.

use original embedded httpd

-- Looking for SQLExecute -- Looking for SQLExecute - found -- unixodbc/unixodbc-dev are installed, and odbc connector will be built -- Found FLEX: /usr/bin/flex (found version "2.6.4") -- Configuring done -- Generating done -- Build files have been written to: /data/pro/tsdb/TDengine/debug [ 0%] Building C object deps/zlib-1.2.11/CMakeFiles/z.dir/src/adler32.c.o error: unknown warning option '-Wno-unused-but-set-variable'; did you mean '-Wno-unused-const-variable'? [-Werror,-Wunknown-warning-option] make[2]: [deps/zlib-1.2.11/CMakeFiles/z.dir/src/adler32.c.o] Error 1 make[1]: [deps/zlib-1.2.11/CMakeFiles/z.dir/all] Error 2 make: *** [all] Error 2

sangshuduo commented 2 years ago

我是 macOS 12.3 clang 13.1.6,没问题。你可以修改一下 cmake/define.inc 文件

IF (CLANG_VERSION_STRING GREATER_EQUAL 13.0) SET(COMMON_FLAGS "${COMMON_FLAGS} -Wno-unused-but-set-variable") ENDIF ()

把 13.0 改为 13.1 试试