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

No output from "Quick start" get-started example: https://docs.kuzudb.com/get-started/ #4997

Closed
raphael10-collab opened this issue Mar 5, 2025 · 0 comments

Comments

@raphael10-collab
Copy link

raphael10-collab commented Mar 5, 2025

While this code

#include <iostream>

#include "kuzu.hpp"
using namespace kuzu::main;

int main() {
    auto database = std::make_unique<Database>("" /* fill db path */);
    auto connection = std::make_unique<Connection>(database.get());

    // Create schema.
    connection->query("CREATE NODE TABLE Person(name STRING, age INT64, PRIMARY KEY(name));");
    // Create nodes.
    connection->query("CREATE (:Person {name: 'Alice', age: 25});");
    connection->query("CREATE (:Person {name: 'Bob', age: 30});");

    // Execute a simple query.
    auto result = connection->query("MATCH (a:Person) RETURN a.name AS NAME, a.age AS AGE;");
    // Print query result.
    std::cout << result->toString();
}

produces this correct output:

(base) raphy@raohy:~/kuzu-cpp$ ./builddir/MyPrj 
NAME|AGE
Alice|25
Bob|30

I get no output from "Quick start" get-started example: https://docs.kuzudb.com/get-started/

(base) raphy@raohy:~/kuzu-cpp$ cmake -B builddir
-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is GNU 14.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.3s)
-- Generating done (0.0s)
-- Build files have been written to: /home/raphy/kuzu-cpp/builddir
(base) raphy@raohy:~/kuzu-cpp$ cmake --build builddir/
[ 50%] Building CXX object CMakeFiles/MyPrj.dir/src/main.cpp.o
[100%] Linking CXX executable MyPrj
[100%] Built target MyPrj
(base) raphy@raohy:~/kuzu-cpp$ ./builddir/MyPrj 
(base) raphy@raohy:~/kuzu-cpp$ 

CMakeLists.txt file :

cmake_minimum_required(VERSION 3.15...3.31)
project(MyPrj)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

#find_package(kuzu)

add_executable(${PROJECT_NAME}
   src/main.cpp
)

target_link_directories(${PROJECT_NAME} PUBLIC
    ./src/KuzuDB/lib
)

target_include_directories(${PROJECT_NAME} PUBLIC
    ./src/KuzuDB/include
)

target_link_libraries(${PROJECT_NAME} PUBLIC
    kuzu
)

source file :

./src/main.cpp :

#include <iostream>

#include "./KuzuDB/include/kuzu.hpp"

using namespace kuzu::main;
using namespace std;

int main() {
    // Create an empty on-disk database and connect to it
    SystemConfig systemConfig;
    auto database = make_unique<Database>("test", systemConfig);

    // Connect to the database.
    auto connection = make_unique<Connection>(database.get());

    // Create the schema.
    connection->query("CREATE NODE TABLE User(name STRING, age INT64, PRIMARY KEY (name))");
    connection->query("CREATE NODE TABLE City(name STRING, population INT64, PRIMARY KEY (name))");
    connection->query("CREATE REL TABLE Follows(FROM User TO User, since INT64)");
    connection->query("CREATE REL TABLE LivesIn(FROM User TO City)");

    // Load data.
    connection->query("COPY User FROM \"user.csv\"");
    connection->query("COPY City FROM \"city.csv\"");
    connection->query("COPY Follows FROM \"follows.csv\"");
    connection->query("COPY LivesIn FROM \"lives-in.csv\"");

    // Execute a simple query.
    auto result =
        connection->query("MATCH (a:User)-[f:Follows]->(b:User) RETURN a.name, f.since, b.name;");

    // Output query result.
    while (result->hasNext()) {
        auto row = result->getNext();
        std::cout << row->getValue(0)->getValue<string>() << " "
                  << row->getValue(1)->getValue<int64_t>() << " "
                  << row->getValue(2)->getValue<string>() << std::endl;
    }
    return 0;
}

Folder content :

(base) raphy@raohy:~/kuzu-cpp$ ls -lah ./src
total 44K
drwxrwxr-x 3 raphy raphy 4,0K mar  5 14:16 .
drwxrwxr-x 6 raphy raphy 4,0K mar  5 14:14 ..
-rw-rw-r-- 1 raphy raphy   46 mar  5 14:07 city.csv
-rw-rw-r-- 1 raphy raphy  196 mar  5 14:07 copy.cypher
-rw-rw-r-- 1 raphy raphy   70 mar  5 14:07 follows.csv
drwxrwxr-x 4 raphy raphy 4,0K mar  5 13:54 KuzuDB
-rw-rw-r-- 1 raphy raphy   60 mar  5 14:07 lives-in.csv
-rw-rw-r-- 1 raphy raphy 1,5K mar  5 14:10 main.cpp
-rw-rw-r-- 1 raphy raphy  689 mar  5 14:04 OLDmain.cpp
-rw-rw-r-- 1 raphy raphy  241 mar  5 14:07 schema.cypher
-rw-rw-r-- 1 raphy raphy   37 mar  5 14:08 user.csv

(base) raphy@raohy:~/kuzu-cpp$ ls -lah ./src/KuzuDB/
total 16K
drwxrwxr-x 4 raphy raphy 4,0K mar  5 13:54 .
drwxrwxr-x 3 raphy raphy 4,0K mar  5 14:16 ..
drwxrwxr-x 2 raphy raphy 4,0K mar  5 13:53 include
drwxrwxr-x 2 raphy raphy 4,0K mar  5 13:54 lib

(base) raphy@raohy:~/kuzu-cpp$ ls -lah ./src/KuzuDB/include/
total 392K
drwxrwxr-x 2 raphy raphy 4,0K mar  5 13:53 .
drwxrwxr-x 4 raphy raphy 4,0K mar  5 13:54 ..
-rw-r--r-- 1 raphy raphy  69K feb 15 09:04 kuzu.h
-rw-r--r-- 1 raphy raphy 312K feb 24 16:49 kuzu.hpp
(base) raphy@raohy:~/kuzu-cpp$ 
(base) raphy@raohy:~/kuzu-cpp$ ls -lah ./src/KuzuDB/lib/
total 22M
drwxrwxr-x 2 raphy raphy 4,0K mar  5 13:54 .
drwxrwxr-x 4 raphy raphy 4,0K mar  5 13:54 ..
-rwxr-xr-x 1 raphy raphy  22M feb 24 16:49 libkuzu.so

OS: Ubuntu 24.04
gcc (Ubuntu 13.3.0-6ubuntu2~24.04) : 13.3.0

What am I missing and / or doing wrong? How to make it work?

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