I created a library project and app project.I want to use the sturct variable which declared in library project,but I can't do that.Why?The code shown as below:
Please help me.Thanks!
You've declared ss as an external, but define it as a local variable on the stack in main(). Make it a global variable in your C-file (outside of the function) and it should work.
The library project can be built successfully.Firstly,I declared a structure in library header file and also defined a extern structure variable. Secondly,I defined a function which used this structure variable in library source file. And then I export from library header file and the variable also used in library source file.Then I defined a same structure variable and call that function in app project.But it reported some errors while building.
I see. But which kind of error? It is possible share output from build console? Or even better - your library and app project?
Hi,
I'm not sure what is your library/project structure. But basically - you need to implement functions in your library code. Structure definition can be done in library header file.
For using your library in your project, you need to tell linker where the library is. Right click on project name -> Properties:
If you specify function/variable as a extern - it tells linker to search such function in other obj files.
Yes,the library path have been set.But it failed when building the project.
Um, sorry - the error is during build, right? Can you please share the output from build console and share screenshot from Linker settings (the window which I shared).
Hi,
how the debug fails? Is there some error message? Did you build your library with debug info?