Questions tagged [linkage]

Linkage describes how names can or can not refer to the same entity throughout the entire program or a single unit. Linkage is particularly useful in C++.

The static keyword is used in to restrict the visibility of a function or variable to its translation unit. This is also valid in .

A name's linkage is related to, but distinct from, its . The scope of a name is the part of a translation unit where it is visible. For instance, a name with global scope (which is the same as file-scope in C and the same as the global namespace-scope in C++) is visible in any part of the file. Its scope will end at the end of the translation unit, whether or not that name has been given external or internal linkage.

If the name has external linkage, the that name denotes may be referred to from another translation unit using a for that same name, and from other scopes within the same translation unit using distinct declarations. Were the name given internal linkage, such a declaration would denote a distinct entity, although using the same name, but its entity could be referred to by distinct declarations within the same translation unit. A name that has no linkage at all cannot be referred to from declarations in different scopes, not even from within the same translation unit. Examples of such names are parameters of functions and local variables. The details differ between C (where only objects and functions - but not types have linkage) and C++ and between this simplified overview.

Static Linking

In static linking, the compiled functions are stored into the executable or dynamic library (if you're creating one).

Dynamic Linking

In dynamic linking, the compiled function is stored in a separated library (DLL in Windows or shared object in Linux). A small piece if code is added to the executable to load that shared library at runtime and map the public functions and variables within it.

639 questions
0
votes
0 answers

Determining entity denoted by name

Declaration introduce name into declarative region. But when the entity denoted by this name does determined? At linking time or at compile time? #include int a=5; int main() { extern int a; //Is it true that entity will be determine…
user2953119
0
votes
2 answers

Why can function defined in a different file access variables defined in that file without extern?

I have two files: main.c and main1.c: main1.c: #include int a = 12; void foo(void) { printf("%d\n", a); } main.c #include #include void foo(void); int main(void) { foo(); } Why does foo() print 12 even if…
user1042840
  • 1,925
  • 2
  • 16
  • 32
0
votes
1 answer

Error #1009 sometimes during game

I have made a game on Flash CS6 using AS3. The game has a spaceship on the right hand of the screen and it shoots bullets at aliens that randomly appear on the right. The game is all working perfectly but every now and then when I play it i get this…
0
votes
2 answers

C compilation error, external library functions not found

I'm trying to compile a project (which is written on a 32bit OS, Ubuntu). I'm using the given makefiles and I installed all the necessary external libraries (on a 64bit Ubuntu). I don't get a library linking error but the functions implemented in…
Elod
  • 499
  • 9
  • 25
0
votes
1 answer

How to create balanced tree in matlab

I'm trying to build a tree in matlab through hierarchical clustering. I tried using the linkage function doing: z=linkage(data); dendrogram(z); It worked fine but the resulting tree was very unbalanced (http://oi61.tinypic.com/6sasgl.jpg). Is there…
0
votes
1 answer

add a library object to stage with no linkage name

I'm trying to import an external SWF to my air app in iOS, and after many hours of troubleshooting have narrowed down the issue to the library objects' linkage names as being the last bit of "external code" that's preventing it from loading…
user3071888
  • 83
  • 10
0
votes
1 answer

implementation of Hierarchial Agglomerative clustering

i am newbie and just want to implement Hierarchical Agglomerative clustering for RGB images. For this I extract all values of RGB from an image. And I process image.Next I find its distance and then develop the linkage. Now from linkage I want to…
mGm
  • 264
  • 2
  • 12
0
votes
2 answers

How to automake C source files

I have a file cmdscan.c that contains just a function and a struct. My main program hsh.c uses the function and struct from cmdscan.c. I followed the instructions on my professor's pdf exactly but it will not work. Even if I edit something save and…
MeesterMarcus
  • 700
  • 1
  • 9
  • 25
0
votes
1 answer

Can't manage to link a cpp file - unresolved external symbol

I'm working with Visual Studio 2008. I have a solution with few projects. On one project (lets call it ProjectX) I have these files: Header file (ExportProject.h) that look like this: #ifndef __CExportProject_H_INCLUDED__ #define…
Itay Gal
  • 10,706
  • 6
  • 36
  • 75
0
votes
1 answer

How can I detect undefined symbols in a binary/library?

Is there a tool that takes a binary (executable) or a library and, looking also into any shared library dependencies, finds and lists any undefined symbols (even if they are not used)? Any practical way of finding this?
ricab
  • 2,697
  • 4
  • 23
  • 28
0
votes
2 answers

Can't run a linkage script through VIM

Hello, I wrote a bash script that compile several cpp's and object files in g++. My goal is to run the script in vim by :!, but it doesn't works within vim, only when I'm outside. In addition I wanted to why using % in a script doesn't give me…
0
votes
0 answers

Scipy linkage() function returning inconsistent results

I have a C# program that does some analysis, prints out a full 2D matrix of distance values, and then launches a scipy python process (anaconda, fwiw) to do hierarchical clustering. Here's the problem: I need to impose some kind of ordering on them…
Denny
  • 33
  • 4
0
votes
1 answer

an in-code keyword for linking a .lib file

I'm using VS2010 to write some win32 app. I normally add .lib files to linkage using to project property manager. yet, sometimes, when I just want to test an API function , I don't want to modify my project file , but rather just add a removable…
0
votes
2 answers

how a linker resolves linkage?

i have two translation units.. file1.c #include #include extern char a[90]; int main(int argc,char ** argv){ //printf("%s ",a); strcat(a,"y Code"); printf("%s",a); return 0; } file2.c char a[4]={'Q','u','i','r'}; by…
Duggs
  • 169
  • 1
  • 12
0
votes
0 answers

Pointer to extending structs using one array

I'm doing a higher complex system for a company. I have the assignment to keep one loop for each (Draw, Update). However their system requires me to extend the base class for the different calculations; and there will be several extenders. What i…