-
Notifications
You must be signed in to change notification settings - Fork 455
Fix build for FreeBSD #1243
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
Fix build for FreeBSD #1243
Conversation
f155a22
to
4185b95
Compare
Some standard library features need __BSD_VISIBLE set to 1 to be enabled on FreeBSD
4185b95
to
8729007
Compare
You can use the following code to test that connecting via SRV works. One might want to connect to an instance on Atlas since the server does not support FreeBSD at this time. #include <mongoc/mongoc.h>
int main (int argc, char **argv)
{
mongoc_client_t *client = NULL;
bson_error_t error = {0};
mongoc_server_api_t *api = NULL;
mongoc_database_t *database = NULL;
bson_t *command = NULL, reply;
// Initialize the MongoDB C Driver.
mongoc_init ();
client = mongoc_client_new("<INSERT_YOUR_CONNECTION_STRING_HERE>");
// Set the version of the Stable API on the client.
api = mongoc_server_api_new (MONGOC_SERVER_API_V1);
if (!mongoc_client_set_server_api (client, api, &error))
{
// Error condition.
printf("Error: %s\n", error.message);
return 0;
}
// Get a handle on the "admin" database.
database = mongoc_client_get_database (client, "admin");
// Ping the database.
command = BCON_NEW("ping", BCON_INT32(1));
if (mongoc_database_command_simple(database, command, NULL, &reply, &error))
{
printf("Pinged your deployment. You successfully connected to MongoDB!\n");
}
else
{
// Error condition.
printf("Error: %s\n", error.message);
return 0;
}
// Perform Cleanup.
bson_destroy (&reply);
bson_destroy (command);
mongoc_database_destroy (database);
mongoc_client_destroy (client);
mongoc_cleanup ();
return 0;
} Running: $ uname
FreeBSD
$ cc test-srv.c -I ~/install/cdriver/include/libmongoc-1.0 -I ~/install/cdriver/include/libbson-1.0 -L ~/install/cdriver/lib/ -lbson-1.0 -lmongoc-1.0 && LD_LIBRARY_PATH=~/install/cdriver/lib ./a.out
Pinged your deployment. You successfully connected to MongoDB! |
Co-authored-by: Kevin Albertson <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one comment addressed.
Co-authored-by: Kevin Albertson <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
CDRIVER-4465