Issue with Undefined References for Global Variables in Static Library

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Issue with Undefined References for Global Variables in Static Library

跳至解决方案
378 次查看
Ranjith_kumar
Contributor II

Dear NXP Team,

I have a source file filename.c and its corresponding header filename.h. Within filename.c, I define and initialize some global variables, which are declared as extern in filename.h.

I have compiled filename.c into a static library file (filename.a). However, when linking this static library, I encounter "undefined reference" errors related to those global variables.

Ranjith_kumar_0-1753764504383.png

 

Could you please provide guidance or best practices on how to correctly manage these global variables with extern declarations and static library creation to resolve the undefined reference issue?

Thank you for your support.

Best regards,

P.Ranjth kumar

0 项奖励
回复
1 解答
339 次查看
_Leo_
NXP TechSupport
NXP TechSupport


Thank you for your interest in our products and for contributing to our community.

Please refer to HOWTO: Add a static library file into S32DS GCC project.

I hope this information is helpful. Feel free to reach out if you have any further questions.

在原帖中查看解决方案

0 项奖励
回复
1 回复
340 次查看
_Leo_
NXP TechSupport
NXP TechSupport


Thank you for your interest in our products and for contributing to our community.

Please refer to HOWTO: Add a static library file into S32DS GCC project.

I hope this information is helpful. Feel free to reach out if you have any further questions.

0 项奖励
回复
%3CLINGO-SUB%20id%3D%22lingo-sub-2142248%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E9%9D%99%E6%80%81%E5%BA%93%E4%B8%AD%E5%85%A8%E5%B1%80%E5%8F%98%E9%87%8F%E7%9A%84%E6%9C%AA%E5%AE%9A%E4%B9%89%E5%8F%82%E8%80%83%E9%97%AE%E9%A2%98%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2142248%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%20class%3D%22%22%3E%E4%BA%B2%E7%88%B1%E7%9A%84%E6%81%A9%E6%99%BA%E6%B5%A6%E5%9B%A2%E9%98%9F%3C%2FP%3E%3CP%20class%3D%22%22%3E%E6%88%91%E6%9C%89%E4%B8%80%E4%B8%AA%E6%BA%90%E6%96%87%E4%BB%B6%3CSPAN%3E%20%3C%2FSPAN%3Efilename.c%3CSPAN%3E%20%3C%2FSPAN%3E%E5%8F%8A%E5%85%B6%E7%9B%B8%E5%BA%94%E7%9A%84%E5%A4%B4%E6%96%87%E4%BB%B6%3CSPAN%3E%20%3C%2FSPAN%3Efilename.h%E3%80%82%3CSPAN%3E%20%3C%2FSPAN%3Efilename.c%20%E5%86%85%E3%80%81%E6%88%91%E5%AE%9A%E4%B9%89%E5%B9%B6%E5%88%9D%E5%A7%8B%E5%8C%96%E4%BA%86%E4%B8%80%E4%BA%9B%E5%85%A8%E5%B1%80%E5%8F%98%E9%87%8F%EF%BC%8C%E5%9C%A8%3CSPAN%3E%20%3C%2FSPAN%3Efilename.h%20%E4%B8%AD%E5%A3%B0%E6%98%8E%E4%B8%BA%3CSPAN%3E%20%3C%2FSPAN%3Eextern%3CSPAN%3E%20%3C%2FSPAN%3E%E3%80%82%3C%2FP%3E%3CP%20class%3D%22%22%3E%E6%88%91%E7%BC%96%E8%AF%91%E4%BA%86%3CSPAN%3E%20%3C%2FSPAN%3Efilename.c%3CSPAN%3E%20%3C%2FSPAN%3E%E5%88%B0%E4%B8%80%E4%B8%AA%E9%9D%99%E6%80%81%E5%BA%93%E6%96%87%E4%BB%B6%EF%BC%88filename.a%EF%BC%89%E4%B8%AD%E3%80%82%E4%BD%86%E6%98%AF%EF%BC%8C%E5%9C%A8%E9%93%BE%E6%8E%A5%E8%BF%99%E4%B8%AA%E9%9D%99%E6%80%81%E5%BA%93%E6%97%B6%EF%BC%8C%E6%88%91%E4%BC%9A%E9%81%87%E5%88%B0%E4%B8%8E%E8%BF%99%E4%BA%9B%E5%85%A8%E5%B1%80%E5%8F%98%E9%87%8F%E6%9C%89%E5%85%B3%E7%9A%84%20%22%20%E6%9C%AA%E5%AE%9A%E4%B9%89%E5%8F%82%E8%80%83%20%22%20%E9%94%99%E8%AF%AF%E3%80%82%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Ranjith_kumar_0-1753764504383.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Ranjith_kumar_0-1753764504383.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F349872i4581D3C7CD9EE3CC%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Ranjith_kumar_0-1753764504383.png%22%20alt%3D%22Ranjith_kumar_0-1753764504383.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%20class%3D%22%22%3E%E6%82%A8%E8%83%BD%E5%90%A6%E6%8F%90%E4%BE%9B%E6%8C%87%E5%AF%BC%E6%88%96%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5%EF%BC%8C%E8%AF%B4%E6%98%8E%E5%A6%82%E4%BD%95%E9%80%9A%E8%BF%87%3CSPAN%3E%3C%2FSPAN%3E%20extern%3CSPAN%3E%3C%2FSPAN%3E%20%E5%A3%B0%E6%98%8E%E5%92%8C%E5%88%9B%E5%BB%BA%E9%9D%99%E6%80%81%E5%BA%93%E6%9D%A5%E6%AD%A3%E7%A1%AE%E7%AE%A1%E7%90%86%E8%BF%99%E4%BA%9B%E5%85%A8%E5%B1%80%E5%8F%98%E9%87%8F%E4%BB%A5%E8%A7%A3%E5%86%B3%E6%9C%AA%E5%AE%9A%E4%B9%89%E7%9A%84%E5%8F%82%E8%80%83%E9%97%AE%E9%A2%98%EF%BC%9F%3C%2FP%3E%3CP%20class%3D%22%22%3E%E6%84%9F%E8%B0%A2%E6%82%A8%E7%9A%84%E6%94%AF%E6%8C%81%E3%80%82%3C%2FP%3E%3CP%20class%3D%22%22%3E%E9%A1%BA%E7%A5%9D%E5%95%86%E7%A5%BA%EF%BC%81%3C%2FP%3E%3CP%20class%3D%22%22%3EP.Ranjth%20kumar%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2146429%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Issue%20with%20Undefined%20References%20for%20Global%20Variables%20in%20Static%20Library%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2146429%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CBR%20%2F%3E%E6%84%9F%E8%B0%A2%E6%82%A8%E5%85%B3%E6%B3%A8%E6%88%91%E4%BB%AC%E7%9A%84%E4%BA%A7%E5%93%81%E5%B9%B6%E4%B8%BA%E6%88%91%E4%BB%AC%E7%9A%84%E7%A4%BE%E5%8C%BA%E5%81%9A%E5%87%BA%E8%B4%A1%E7%8C%AE%E3%80%82%3C%2FP%3E%0A%3CP%3E%E8%AF%B7%E5%8F%82%E9%98%85%20%22%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32-Design-Studio-Knowledge-Base%2FHOWTO-Add-a-static-library-file-into-S32DS-GCC-project%2Fta-p%2F1110308%22%20target%3D%22_blank%22%3E%E5%A6%82%E4%BD%95%EF%BC%9A%E5%9C%A8%20S32DS%20GCC%20%E9%A1%B9%E7%9B%AE%E4%B8%AD%E6%B7%BB%E5%8A%A0%E9%9D%99%E6%80%81%E5%BA%93%E6%96%87%E4%BB%B6%22%E3%80%82%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%E5%B8%8C%E6%9C%9B%E8%BF%99%E4%BA%9B%E4%BF%A1%E6%81%AF%E5%AF%B9%E6%82%A8%E6%9C%89%E6%89%80%E5%B8%AE%E5%8A%A9%E3%80%82%E5%A6%82%E6%9C%89%E4%BB%BB%E4%BD%95%E7%96%91%E9%97%AE%EF%BC%8C%E8%AF%B7%E9%9A%8F%E6%97%B6%E8%81%94%E7%B3%BB%E6%88%91%E4%BB%AC%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E