Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within C / C++
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Paul Clapham
Tim Cooke
Ron McLeod
Liutauras Vilda
Sheriffs:
Jeanne Boyarsky
Devaka Cooray
Junilu Lacar
Saloon Keepers:
Tim Holloway
Carey Brown
Stephan van Hulst
Peter Rooke
Mikalai Zaikin
Bartenders:
Himai Minh
Forum:
C / C++
clang: error: linker command failed with exit code 1 (use -v to see invocation) MINIX3
El Ban
Greenhorn
Posts: 1
posted 7 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Using clang to compile an application on Minix3 and having a little bit of trouble.
I want to implement an interprocess communication by message passing and getting this error (my file is send.cpp):
send.cpp:(.text+0x7f): undefined reference to `msgget' send.cpp:(.text+0x1c1): undefined reference to `msgsnd' clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is my send.cpp file:
#include <sys/types.h> #include <sys/msg.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <chrono> #include <iostream> #define MSGSZ 128 using namespace std::chrono; /* * Declare the message structure. */ typedef struct msgbufer { long mtype; char mtext[MSGSZ]; } message_buf; int main() { int msqid; int msgflg = IPC_CREAT | 0666; key_t key; message_buf sbuf; size_t buf_length; /* * Get the message queue id for the * "name" 1234, which was created by * the server. */ key = 1234; (void) fprintf(stderr, "\nmsgget: Calling msgget(%i,\ %#o)\n", key, msgflg); if ((msqid = msgget(key, msgflg )) < 0) { perror("msgget"); exit(1); } else (void) fprintf(stderr,"msgget: msgget succeeded: msqid = %d\n", msqid); /* * We'll send message type 1 */ sbuf.mtype = 1; (void) strcpy(sbuf.mtext, "Hello other process 2."); buf_length = strlen(sbuf.mtext) + 1 ; /* * Send a message. */ high_resolution_clock::time_point t1 = high_resolution_clock::now(); int err = msgsnd(msqid, &sbuf, buf_length, IPC_NOWAIT); high_resolution_clock::time_point t2 = high_resolution_clock::now(); if (err < 0) { printf ("%d, %li, %s, %lu\n", msqid, sbuf.mtype, sbuf.mtext, buf_length); perror("msgsnd"); exit(1); } else printf("Message: \"%s\" Sent\n", sbuf.mtext); auto duration = duration_cast<nanoseconds>( t2 - t1 ).count(); std::cout << "Execution duration: " << duration << std::endl; exit(0); }
Any idea?
Catch Ernie! Catch the egg! And catch this tiny ad too:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
how to simulate MouseEvent without using mouse for java program?
Help with c++ and cmd.exe
JNI : Creating a JVM
File Locing on CIFS
How do you use header files?
More...