Building custom glibc and compiling program against it












2














I've been scouring the internet for a couple of days now to get some information on how to (cross)compile glibc and then compile a program against it.



So far, I've managed to compile glibc using the following commands
../configure arm-none-linux-gnueabi --host=arm-none-linux-gnueabi --target=arm-linux-gnueabi --prefix=`pwd` --build=i686-pc-linux-gnu`
make -j4



As for the program itself, I followed this post and it all seemed to work..Until I realized that none of the changes that I made to glibc were reflecting.



To come up with a test to verify whether the library was infact being linked against, I made the following changes:

I modified include/signal.h and added extern int my_test_fn(void);

I then modified signal/signal.c first and then sysdeps/posix/signal.c and went on to add the function definition as follows:



int my_test_fn() {
errno=13; //EACCESS
}


When I tried compiling my program, it threw up
In function `tuning_library_init':
/home/guru/workspace/tuning-library/tuning_library.c:1076: undefined reference to `my_test_fn'
collect2: error: ld returned 1 exit status
make: *** [host] Error 1










share|improve this question
















bumped to the homepage by Community 2 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • stackoverflow.com/questions/10763394/…
    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    May 26 '15 at 20:05
















2














I've been scouring the internet for a couple of days now to get some information on how to (cross)compile glibc and then compile a program against it.



So far, I've managed to compile glibc using the following commands
../configure arm-none-linux-gnueabi --host=arm-none-linux-gnueabi --target=arm-linux-gnueabi --prefix=`pwd` --build=i686-pc-linux-gnu`
make -j4



As for the program itself, I followed this post and it all seemed to work..Until I realized that none of the changes that I made to glibc were reflecting.



To come up with a test to verify whether the library was infact being linked against, I made the following changes:

I modified include/signal.h and added extern int my_test_fn(void);

I then modified signal/signal.c first and then sysdeps/posix/signal.c and went on to add the function definition as follows:



int my_test_fn() {
errno=13; //EACCESS
}


When I tried compiling my program, it threw up
In function `tuning_library_init':
/home/guru/workspace/tuning-library/tuning_library.c:1076: undefined reference to `my_test_fn'
collect2: error: ld returned 1 exit status
make: *** [host] Error 1










share|improve this question
















bumped to the homepage by Community 2 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • stackoverflow.com/questions/10763394/…
    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    May 26 '15 at 20:05














2












2








2







I've been scouring the internet for a couple of days now to get some information on how to (cross)compile glibc and then compile a program against it.



So far, I've managed to compile glibc using the following commands
../configure arm-none-linux-gnueabi --host=arm-none-linux-gnueabi --target=arm-linux-gnueabi --prefix=`pwd` --build=i686-pc-linux-gnu`
make -j4



As for the program itself, I followed this post and it all seemed to work..Until I realized that none of the changes that I made to glibc were reflecting.



To come up with a test to verify whether the library was infact being linked against, I made the following changes:

I modified include/signal.h and added extern int my_test_fn(void);

I then modified signal/signal.c first and then sysdeps/posix/signal.c and went on to add the function definition as follows:



int my_test_fn() {
errno=13; //EACCESS
}


When I tried compiling my program, it threw up
In function `tuning_library_init':
/home/guru/workspace/tuning-library/tuning_library.c:1076: undefined reference to `my_test_fn'
collect2: error: ld returned 1 exit status
make: *** [host] Error 1










share|improve this question















I've been scouring the internet for a couple of days now to get some information on how to (cross)compile glibc and then compile a program against it.



So far, I've managed to compile glibc using the following commands
../configure arm-none-linux-gnueabi --host=arm-none-linux-gnueabi --target=arm-linux-gnueabi --prefix=`pwd` --build=i686-pc-linux-gnu`
make -j4



As for the program itself, I followed this post and it all seemed to work..Until I realized that none of the changes that I made to glibc were reflecting.



To come up with a test to verify whether the library was infact being linked against, I made the following changes:

I modified include/signal.h and added extern int my_test_fn(void);

I then modified signal/signal.c first and then sysdeps/posix/signal.c and went on to add the function definition as follows:



int my_test_fn() {
errno=13; //EACCESS
}


When I tried compiling my program, it threw up
In function `tuning_library_init':
/home/guru/workspace/tuning-library/tuning_library.c:1076: undefined reference to `my_test_fn'
collect2: error: ld returned 1 exit status
make: *** [host] Error 1







glibc cross-compilation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 23 '17 at 12:40









Community

1




1










asked Sep 5 '14 at 18:01









Guru Prasad

128124




128124





bumped to the homepage by Community 2 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 2 hours ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • stackoverflow.com/questions/10763394/…
    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    May 26 '15 at 20:05


















  • stackoverflow.com/questions/10763394/…
    – Ciro Santilli 新疆改造中心 六四事件 法轮功
    May 26 '15 at 20:05
















stackoverflow.com/questions/10763394/…
– Ciro Santilli 新疆改造中心 六四事件 法轮功
May 26 '15 at 20:05




stackoverflow.com/questions/10763394/…
– Ciro Santilli 新疆改造中心 六四事件 法轮功
May 26 '15 at 20:05










1 Answer
1






active

oldest

votes


















0














Before you go to far:



Read this guide on ARM cross-compiling to understand the basic principles. The steps used there are ALWAYS a GENERAL GUIDELINE, regardless of versions used. For something more in-depth that you will learn from, navigate the CLFS Wiki to download or read the current Stable book. Follow the book until you finish building the cross-compiled toolchain, then deviate from the book to start building whatever you need to cross-compile for.



You don't just cross-compile glibc, you need to cross-compile an entire toolchain. Toolchain components are ALWAYS:





  1. BinUtils, for the assembler and linker

  2. A compiler, most likely GCC

  3. A C Library, most likely Glibc or ucLibc for Embedded Platforms

  4. A Debugger, most likely GDB


See: eLinux's Wiki Entry on Toolchains and WikiPedia's Entry on the GNU Toolchain.



They must also be built in a particular order each time you target a new architecture. You'll learn that order by reading either of the links above, although the CLFS Book will provide step by step commands, with rather well written explanations, and the reasoning behind doing so. I recommend starting your process over, after a tall cup of Coffee or Mountain Dew, as the first few times you do this it will take you a few days. As you do it more and the process becomes ingrained, it will take anywhere between 4 - 6 hours.





A common gotcha here, is that people will accidentally mix up their host headers and toolchain with the cross-compiled headers, which may be what you have done. The header files you should include in your cross-compile chain should be stored in someplace like /home/username/usr/local/include so as not to contaminate your host.






share|improve this answer























  • Your links are broken, can you please quote the relevant parts if you remember?
    – Calmarius
    Mar 22 '18 at 7:11










  • @Calmarius Links have been fixed.
    – eyoung100
    Mar 22 '18 at 19:32











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f154014%2fbuilding-custom-glibc-and-compiling-program-against-it%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









0














Before you go to far:



Read this guide on ARM cross-compiling to understand the basic principles. The steps used there are ALWAYS a GENERAL GUIDELINE, regardless of versions used. For something more in-depth that you will learn from, navigate the CLFS Wiki to download or read the current Stable book. Follow the book until you finish building the cross-compiled toolchain, then deviate from the book to start building whatever you need to cross-compile for.



You don't just cross-compile glibc, you need to cross-compile an entire toolchain. Toolchain components are ALWAYS:





  1. BinUtils, for the assembler and linker

  2. A compiler, most likely GCC

  3. A C Library, most likely Glibc or ucLibc for Embedded Platforms

  4. A Debugger, most likely GDB


See: eLinux's Wiki Entry on Toolchains and WikiPedia's Entry on the GNU Toolchain.



They must also be built in a particular order each time you target a new architecture. You'll learn that order by reading either of the links above, although the CLFS Book will provide step by step commands, with rather well written explanations, and the reasoning behind doing so. I recommend starting your process over, after a tall cup of Coffee or Mountain Dew, as the first few times you do this it will take you a few days. As you do it more and the process becomes ingrained, it will take anywhere between 4 - 6 hours.





A common gotcha here, is that people will accidentally mix up their host headers and toolchain with the cross-compiled headers, which may be what you have done. The header files you should include in your cross-compile chain should be stored in someplace like /home/username/usr/local/include so as not to contaminate your host.






share|improve this answer























  • Your links are broken, can you please quote the relevant parts if you remember?
    – Calmarius
    Mar 22 '18 at 7:11










  • @Calmarius Links have been fixed.
    – eyoung100
    Mar 22 '18 at 19:32
















0














Before you go to far:



Read this guide on ARM cross-compiling to understand the basic principles. The steps used there are ALWAYS a GENERAL GUIDELINE, regardless of versions used. For something more in-depth that you will learn from, navigate the CLFS Wiki to download or read the current Stable book. Follow the book until you finish building the cross-compiled toolchain, then deviate from the book to start building whatever you need to cross-compile for.



You don't just cross-compile glibc, you need to cross-compile an entire toolchain. Toolchain components are ALWAYS:





  1. BinUtils, for the assembler and linker

  2. A compiler, most likely GCC

  3. A C Library, most likely Glibc or ucLibc for Embedded Platforms

  4. A Debugger, most likely GDB


See: eLinux's Wiki Entry on Toolchains and WikiPedia's Entry on the GNU Toolchain.



They must also be built in a particular order each time you target a new architecture. You'll learn that order by reading either of the links above, although the CLFS Book will provide step by step commands, with rather well written explanations, and the reasoning behind doing so. I recommend starting your process over, after a tall cup of Coffee or Mountain Dew, as the first few times you do this it will take you a few days. As you do it more and the process becomes ingrained, it will take anywhere between 4 - 6 hours.





A common gotcha here, is that people will accidentally mix up their host headers and toolchain with the cross-compiled headers, which may be what you have done. The header files you should include in your cross-compile chain should be stored in someplace like /home/username/usr/local/include so as not to contaminate your host.






share|improve this answer























  • Your links are broken, can you please quote the relevant parts if you remember?
    – Calmarius
    Mar 22 '18 at 7:11










  • @Calmarius Links have been fixed.
    – eyoung100
    Mar 22 '18 at 19:32














0












0








0






Before you go to far:



Read this guide on ARM cross-compiling to understand the basic principles. The steps used there are ALWAYS a GENERAL GUIDELINE, regardless of versions used. For something more in-depth that you will learn from, navigate the CLFS Wiki to download or read the current Stable book. Follow the book until you finish building the cross-compiled toolchain, then deviate from the book to start building whatever you need to cross-compile for.



You don't just cross-compile glibc, you need to cross-compile an entire toolchain. Toolchain components are ALWAYS:





  1. BinUtils, for the assembler and linker

  2. A compiler, most likely GCC

  3. A C Library, most likely Glibc or ucLibc for Embedded Platforms

  4. A Debugger, most likely GDB


See: eLinux's Wiki Entry on Toolchains and WikiPedia's Entry on the GNU Toolchain.



They must also be built in a particular order each time you target a new architecture. You'll learn that order by reading either of the links above, although the CLFS Book will provide step by step commands, with rather well written explanations, and the reasoning behind doing so. I recommend starting your process over, after a tall cup of Coffee or Mountain Dew, as the first few times you do this it will take you a few days. As you do it more and the process becomes ingrained, it will take anywhere between 4 - 6 hours.





A common gotcha here, is that people will accidentally mix up their host headers and toolchain with the cross-compiled headers, which may be what you have done. The header files you should include in your cross-compile chain should be stored in someplace like /home/username/usr/local/include so as not to contaminate your host.






share|improve this answer














Before you go to far:



Read this guide on ARM cross-compiling to understand the basic principles. The steps used there are ALWAYS a GENERAL GUIDELINE, regardless of versions used. For something more in-depth that you will learn from, navigate the CLFS Wiki to download or read the current Stable book. Follow the book until you finish building the cross-compiled toolchain, then deviate from the book to start building whatever you need to cross-compile for.



You don't just cross-compile glibc, you need to cross-compile an entire toolchain. Toolchain components are ALWAYS:





  1. BinUtils, for the assembler and linker

  2. A compiler, most likely GCC

  3. A C Library, most likely Glibc or ucLibc for Embedded Platforms

  4. A Debugger, most likely GDB


See: eLinux's Wiki Entry on Toolchains and WikiPedia's Entry on the GNU Toolchain.



They must also be built in a particular order each time you target a new architecture. You'll learn that order by reading either of the links above, although the CLFS Book will provide step by step commands, with rather well written explanations, and the reasoning behind doing so. I recommend starting your process over, after a tall cup of Coffee or Mountain Dew, as the first few times you do this it will take you a few days. As you do it more and the process becomes ingrained, it will take anywhere between 4 - 6 hours.





A common gotcha here, is that people will accidentally mix up their host headers and toolchain with the cross-compiled headers, which may be what you have done. The header files you should include in your cross-compile chain should be stored in someplace like /home/username/usr/local/include so as not to contaminate your host.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 22 '18 at 19:30

























answered Sep 5 '14 at 18:15









eyoung100

4,7801441




4,7801441












  • Your links are broken, can you please quote the relevant parts if you remember?
    – Calmarius
    Mar 22 '18 at 7:11










  • @Calmarius Links have been fixed.
    – eyoung100
    Mar 22 '18 at 19:32


















  • Your links are broken, can you please quote the relevant parts if you remember?
    – Calmarius
    Mar 22 '18 at 7:11










  • @Calmarius Links have been fixed.
    – eyoung100
    Mar 22 '18 at 19:32
















Your links are broken, can you please quote the relevant parts if you remember?
– Calmarius
Mar 22 '18 at 7:11




Your links are broken, can you please quote the relevant parts if you remember?
– Calmarius
Mar 22 '18 at 7:11












@Calmarius Links have been fixed.
– eyoung100
Mar 22 '18 at 19:32




@Calmarius Links have been fixed.
– eyoung100
Mar 22 '18 at 19:32


















draft saved

draft discarded




















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • 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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f154014%2fbuilding-custom-glibc-and-compiling-program-against-it%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

濃尾地震

How to rewrite equation of hyperbola in standard form

No ethernet ip address in my vocore2