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

C++ API does not work #4144

Closed
vdemichev opened this issue Jul 17, 2022 · 20 comments
Closed

C++ API does not work #4144

vdemichev opened this issue Jul 17, 2022 · 20 comments
Labels

Comments

@vdemichev
Copy link

What happens?

Any query results in parser error.

To Reproduce

#include "duckdb.hpp"

using namespace duckdb;

int main() {
	DuckDB db;
	Connection con(db);

	con.Query("CREATE TABLE people(id INTEGER, name VARCHAR)")->Print();
	return 0;
}

Output: parser error, with random details:
One run:

Parser Error: syntax error at or near "8"
LINE 1: 8?x?♦
Another run:
Parser Error: syntax error at or near "X?O2B"
LINE 1: X?O2B

I was trying to run sample code from https://duckdb.org/docs/data/appender.

Environment (please complete the following information):

Identity Disclosure:

  • Full Name: Vadim Demichev
  • Affiliation: Charite University Medicine Berlin
@Mytherin
Copy link
Collaborator

As what encoding are you saving the file? DuckDB expects UTF8 encoded strings.

@vdemichev
Copy link
Author

I am not sure where I need to change the encoding. I tried both /utf-8 compiler flag in MSVC and replacing the query with
con.Query(u8"CREATE TABLE people(id INTEGER, name VARCHAR)")->Print();
The problem is still there...

@vdemichev
Copy link
Author

This C interface example https://github.com/duckdb/duckdb/blob/master/examples/embedded-c/main.c works fine though...

@virtualsafety
Copy link

This C interface example https://github.com/duckdb/duckdb/blob/master/examples/embedded-c/main.c works fine though...

i am facing the same problem. C example can work fine ,but c++ can not.

@virtualsafety
Copy link

g++.exe -fdiagnostics-color=always -g -I"D:\Go\c-demo\c++" -L"D:\Go\c-demo\c++" -llibduckdb duckdb_cppintegration.cpp -o duckdb_cppintegration -std=c++11
In file included from duckdb_cppintegration.cpp:8:
duckdb.hpp:789:20: error: function 'duckdb::hugeint_t::hugeint_t()' definition is marked dllimport
789 | DUCKDB_API hugeint_t() = default;
| ^~~~~~~~~
duckdb.hpp:791:20: error: function 'duckdb::hugeint_t::hugeint_t(const duckdb::hugeint_t&)' definition is marked dllimport
791 | DUCKDB_API hugeint_t(const hugeint_t &rhs) = default;

@hannes
Copy link
Member

hannes commented Oct 3, 2022

Are you sure this is using MVSC? To me it looks like you are using G++/MinGW or something like that.

@virtualsafety
Copy link

Are you sure this is using MVSC? To me it looks like you are using G++/MinGW or something like that.

yes,i am using MinGW.

@virtualsafety
Copy link

Is it possible to support MinGW?

@Mytherin
Copy link
Collaborator

We don't actively support MinGW right now, aside from as part of the R client.

@github-actions
Copy link

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the stale label Sep 12, 2023
@arnabanimesh
Copy link

Keeping this issue alive because duckdb doesn't work with windows msvc using C++ API.

@Mause
Copy link
Member

Mause commented Sep 12, 2023

Keeping this issue alive because duckdb doesn't work with windows msvc using C++ API.

This issue seems to be about MingW, not MSVC. We don't support MingW, but we definitely do support MSVC, as that's how we compile for Windows. If you're having an issue with MSVC, please create an issue with a full reproduction

@github-actions github-actions bot removed the stale label Sep 13, 2023
@arnabanimesh
Copy link

I'll open another issue shortly using the latest stable release, but the original post in this thread is posted keeping msvc in mind and not mingw.

I tried building the example app with /utf-8 flag using latest stable msvc. It built successfully, but wouldn't show any output.

@Mause
Copy link
Member

Mause commented Sep 16, 2023

@arnabanimesh what do you mean "wouldn't show any output"?

@arnabanimesh
Copy link

arnabanimesh commented Sep 16, 2023 via email

@Mause
Copy link
Member

Mause commented Sep 16, 2023

I would do result -> print(); but it wouldn't show any output.

Even normal cout in the first line of the program wouldn't print anything. Cout prints properly if I remove every line associated with duckdb.

On Sat, 16 Sept, 2023, 9:31 am Elliana May, @.***>
wrote:

@arnabanimesh https://github.com/arnabanimesh what do you mean
"wouldn't show any output"?


Reply to this email directly, view it on GitHub
#4144 (comment),
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABOAZSBOZ3YRF7DB33SI2MLX2UQBXANCNFSM532EGLCA
.
You are receiving this because you were mentioned.Message ID:
@.***>

Can you provide a sample of the code you're running?

@arnabanimesh
Copy link

It works when I built the main branch on my system. C++ API doesn't work when using the 0.8.1 version.

Copy link

github-actions bot commented Jan 6, 2024

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the stale label Jan 6, 2024
Copy link

github-actions bot commented Feb 6, 2024

This issue was closed because it has been stale for 30 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants