Undefined symbols for architecture x86_64 and linker command failed with exit code 1
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I run the following code from APUE
#include "apue.h"
#include <sys/wait.h>
void pr_exit(int status)
{
if (WIFEXITED(status))
printf("normal termination, exit status = %dn",
WEXITSTATUS(status));
else if (WIFSIGNALED(status))
printf("abnormal termination, signal number = %d%sn",
WTERMSIG(status),
#ifdef WCOREDUMP
WCOREDUMP(status) ? " (core file generated)" : "");
#else
"");
#endif
else if (WIFSTOPPED(status))
printf("child stopped, signal number = %dn",
WSTOPSIG(status));
}
but get error:
$ cc my_wait.c
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I checked multiple times and ensure there no difference with the book's instruction ..
How could I solve the problem?
c
add a comment |
I run the following code from APUE
#include "apue.h"
#include <sys/wait.h>
void pr_exit(int status)
{
if (WIFEXITED(status))
printf("normal termination, exit status = %dn",
WEXITSTATUS(status));
else if (WIFSIGNALED(status))
printf("abnormal termination, signal number = %d%sn",
WTERMSIG(status),
#ifdef WCOREDUMP
WCOREDUMP(status) ? " (core file generated)" : "");
#else
"");
#endif
else if (WIFSTOPPED(status))
printf("child stopped, signal number = %dn",
WSTOPSIG(status));
}
but get error:
$ cc my_wait.c
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I checked multiple times and ensure there no difference with the book's instruction ..
How could I solve the problem?
c
It seems you need to get a beginners book or two about C and read from the very start.
– Some programmer dude
Nov 17 '18 at 5:05
1
The error message says "there is no functionmain()
", and the source code you show has no functionmain()
, so there's minimal surprise that there's an error message. Where did you thinkmain()
was going to come from?
– Jonathan Leffler
Nov 17 '18 at 5:30
ty, could you please transmit the comment to answer. @JonathanLeffler
– JawSaw
Nov 17 '18 at 6:47
add a comment |
I run the following code from APUE
#include "apue.h"
#include <sys/wait.h>
void pr_exit(int status)
{
if (WIFEXITED(status))
printf("normal termination, exit status = %dn",
WEXITSTATUS(status));
else if (WIFSIGNALED(status))
printf("abnormal termination, signal number = %d%sn",
WTERMSIG(status),
#ifdef WCOREDUMP
WCOREDUMP(status) ? " (core file generated)" : "");
#else
"");
#endif
else if (WIFSTOPPED(status))
printf("child stopped, signal number = %dn",
WSTOPSIG(status));
}
but get error:
$ cc my_wait.c
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I checked multiple times and ensure there no difference with the book's instruction ..
How could I solve the problem?
c
I run the following code from APUE
#include "apue.h"
#include <sys/wait.h>
void pr_exit(int status)
{
if (WIFEXITED(status))
printf("normal termination, exit status = %dn",
WEXITSTATUS(status));
else if (WIFSIGNALED(status))
printf("abnormal termination, signal number = %d%sn",
WTERMSIG(status),
#ifdef WCOREDUMP
WCOREDUMP(status) ? " (core file generated)" : "");
#else
"");
#endif
else if (WIFSTOPPED(status))
printf("child stopped, signal number = %dn",
WSTOPSIG(status));
}
but get error:
$ cc my_wait.c
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I checked multiple times and ensure there no difference with the book's instruction ..
How could I solve the problem?
c
c
asked Nov 17 '18 at 5:04
JawSawJawSaw
4,97311940
4,97311940
It seems you need to get a beginners book or two about C and read from the very start.
– Some programmer dude
Nov 17 '18 at 5:05
1
The error message says "there is no functionmain()
", and the source code you show has no functionmain()
, so there's minimal surprise that there's an error message. Where did you thinkmain()
was going to come from?
– Jonathan Leffler
Nov 17 '18 at 5:30
ty, could you please transmit the comment to answer. @JonathanLeffler
– JawSaw
Nov 17 '18 at 6:47
add a comment |
It seems you need to get a beginners book or two about C and read from the very start.
– Some programmer dude
Nov 17 '18 at 5:05
1
The error message says "there is no functionmain()
", and the source code you show has no functionmain()
, so there's minimal surprise that there's an error message. Where did you thinkmain()
was going to come from?
– Jonathan Leffler
Nov 17 '18 at 5:30
ty, could you please transmit the comment to answer. @JonathanLeffler
– JawSaw
Nov 17 '18 at 6:47
It seems you need to get a beginners book or two about C and read from the very start.
– Some programmer dude
Nov 17 '18 at 5:05
It seems you need to get a beginners book or two about C and read from the very start.
– Some programmer dude
Nov 17 '18 at 5:05
1
1
The error message says "there is no function
main()
", and the source code you show has no function main()
, so there's minimal surprise that there's an error message. Where did you think main()
was going to come from?– Jonathan Leffler
Nov 17 '18 at 5:30
The error message says "there is no function
main()
", and the source code you show has no function main()
, so there's minimal surprise that there's an error message. Where did you think main()
was going to come from?– Jonathan Leffler
Nov 17 '18 at 5:30
ty, could you please transmit the comment to answer. @JonathanLeffler
– JawSaw
Nov 17 '18 at 6:47
ty, could you please transmit the comment to answer. @JonathanLeffler
– JawSaw
Nov 17 '18 at 6:47
add a comment |
1 Answer
1
active
oldest
votes
Transferring a comment into an answer, as requested.
The error message says "there is no function main()
", and the source code you show has no function main()
, so there's minimal surprise that there's that error message.
Where did you think main()
was going to come from?
When you build a program, there needs to be a main()
from somewhere, and the standard C library does not provide an implementation. (If you work with Flex or Lex, or Bison or Yacc, you may find minimal main()
programs in their libraries, but these are an exception, not the rule.)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53348398%2fundefined-symbols-for-architecture-x86-64-and-linker-command-failed-with-exit-co%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Transferring a comment into an answer, as requested.
The error message says "there is no function main()
", and the source code you show has no function main()
, so there's minimal surprise that there's that error message.
Where did you think main()
was going to come from?
When you build a program, there needs to be a main()
from somewhere, and the standard C library does not provide an implementation. (If you work with Flex or Lex, or Bison or Yacc, you may find minimal main()
programs in their libraries, but these are an exception, not the rule.)
add a comment |
Transferring a comment into an answer, as requested.
The error message says "there is no function main()
", and the source code you show has no function main()
, so there's minimal surprise that there's that error message.
Where did you think main()
was going to come from?
When you build a program, there needs to be a main()
from somewhere, and the standard C library does not provide an implementation. (If you work with Flex or Lex, or Bison or Yacc, you may find minimal main()
programs in their libraries, but these are an exception, not the rule.)
add a comment |
Transferring a comment into an answer, as requested.
The error message says "there is no function main()
", and the source code you show has no function main()
, so there's minimal surprise that there's that error message.
Where did you think main()
was going to come from?
When you build a program, there needs to be a main()
from somewhere, and the standard C library does not provide an implementation. (If you work with Flex or Lex, or Bison or Yacc, you may find minimal main()
programs in their libraries, but these are an exception, not the rule.)
Transferring a comment into an answer, as requested.
The error message says "there is no function main()
", and the source code you show has no function main()
, so there's minimal surprise that there's that error message.
Where did you think main()
was going to come from?
When you build a program, there needs to be a main()
from somewhere, and the standard C library does not provide an implementation. (If you work with Flex or Lex, or Bison or Yacc, you may find minimal main()
programs in their libraries, but these are an exception, not the rule.)
answered Nov 17 '18 at 6:50
Jonathan LefflerJonathan Leffler
576k956911043
576k956911043
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53348398%2fundefined-symbols-for-architecture-x86-64-and-linker-command-failed-with-exit-co%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It seems you need to get a beginners book or two about C and read from the very start.
– Some programmer dude
Nov 17 '18 at 5:05
1
The error message says "there is no function
main()
", and the source code you show has no functionmain()
, so there's minimal surprise that there's an error message. Where did you thinkmain()
was going to come from?– Jonathan Leffler
Nov 17 '18 at 5:30
ty, could you please transmit the comment to answer. @JonathanLeffler
– JawSaw
Nov 17 '18 at 6:47