PDA

View Full Version : รบกวนด้วยครับ



tarn6388
28-03-2009, 02:53 AM
คือพึ่งหัดเขียนครับ

พอดีมานเกิด error ขึ้นครับ

--------------------Configuration: math - Win32 Debug--------------------
Linking...
math2.obj : error LNK2005: _main already defined in math1.obj
Debug/math.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

math.exe - 2 error(s), 0 warning(s)

อยากทราบว่าจะแก้ยังไง

asylu3
28-03-2009, 05:37 AM
post source code ด้วยได้ไหมครับ

Edkung_
28-03-2009, 08:33 AM
ข้อมูลมากว้างๆ ก็ตอบให้แบบกว้างๆ ละกัน (จริงๆ ไม่อยากตอบเลย ให้ข้อมูลมาแบบนี้ ปรับปรุงด้วยนะครับ)

This error is followed by fatal error LNK1169.

To fix by checking the following possible causes

1.

Mixing static and dynamic libraries when also using /clr.
2.

The symbol is a packaged function (created by compiling with /Gy) and was included in more than one file but was changed between compilations. Recompile all files that include symbol.
3.

The symbol is defined differently in two member objects in different libraries, and both member objects were used.
4.

An absolute is defined twice, with a different value in each definition.
5.

A header file declared and defined a variable. Possible solutions include:
*

Declare the variable in .h: extern BOOL MyBool; and then assign to it in a .c or .cpp file: BOOL MyBool = FALSE;.
*

Declare the variable static.
*

Declare the variable selectany.
6.

If you use uuid.lib in combination with other .lib files that define GUIDs (for example, oledb.lib and adsiid.lib). For example:

oledb.lib(oledb_i.obj) : error LNK2005: _IID_ITransactionObject
already defined in uuid.lib(go7.obj)

To fix, add /FORCE:MULTIPLE to the linker command line options, and make sure that uuid.lib is the first library referenced.

Reference by MSDN : http://msdn.microsoft.com/en-us/library/72zdcz6f(VS.80).aspx

labyrinth
05-04-2009, 02:38 PM
ดูจาก Error message ก็พอเดาได้ว่า

สร้าง project ที่มี demo หลายตัว จริงๆแล้วแต่ละไฟล์ สามารถ compile แล้ว Run ได้เลย
ลองแยกออกเป็น แต่ละ project ไปนะ

สาเหตุคือ
- function main มีมากกว่า 1 อัน (ทั้ง project มีได้แค่ อันเดียว)

ถ้าไม่หาย ลอง Rebuild