OLD | NEW |
---|---|
1 # The Chrome Component Build | 1 # The Chrome Component Build |
2 | 2 |
3 ## Introduction | 3 ## Introduction |
4 | 4 |
5 Release builds are “static” builds which compile to one executable and | 5 Release builds are “static” builds which compile to one executable and |
6 zero-to-two shared libraries (depending on the platform). This is efficient at | 6 zero-to-two shared libraries (depending on the platform). This is efficient at |
7 runtime, but can take a long time to link because so much code goes into a | 7 runtime, but can take a long time to link because so much code goes into a |
8 single binary. | 8 single binary. |
9 | 9 |
10 In a component build, many smaller shared libraries will be generated. This | 10 In a component build, many smaller shared libraries will be generated. This |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 cases above where `_IMPLEMENTATION` is inappropriately defined or inappropriatel y | 246 cases above where `_IMPLEMENTATION` is inappropriately defined or inappropriatel y |
247 undefined. Use GN visibility to make sure callers don’t screw up. | 247 undefined. Use GN visibility to make sure callers don’t screw up. |
248 | 248 |
249 ### Putting exported symbols in static libraries | 249 ### Putting exported symbols in static libraries |
250 | 250 |
251 As discussed above, exported symbols should not be in static libraries because | 251 As discussed above, exported symbols should not be in static libraries because |
252 the object file might not be brought into the link. Even if it is brought in | 252 the object file might not be brought into the link. Even if it is brought in |
253 today, it might not be brought in due to completely unrelated changes in the | 253 today, it might not be brought in due to completely unrelated changes in the |
254 future. The result will be undefined symbol errors from other components. Use | 254 future. The result will be undefined symbol errors from other components. Use |
255 source sets if your component is made up of more than one target. | 255 source sets if your component is made up of more than one target. |
256 | |
257 ### Exporting a symbol that is not linked in your component | |
brettw
2017/02/09 21:58:44
I think the confusion you ran into is specific to
| |
258 | |
259 If an exported symbols is not linked as part of its own component then it is | |
260 not exported by the generated shared library. Other components that expect to | |
261 see this symbol are not be able to find it which results in an undefined symbol | |
262 error: | |
263 | |
264 some_file.obj : error LNK2001: unresolved external symbol <some definition> | |
265 | |
266 For example this can happen if you have a header-only class that is not used | |
267 inside the module itself. A simple fix in this case is to define the symbol in | |
268 its own .cpp file. | |
OLD | NEW |